Request.Form in Javascript

M

magix

Hi,

Can I:

<script language="javascript">
var TimeSec = new String (Request.form("TimeInSec"));


or

<script language="javascript">
var TimeSec = new int(Request.form("TimeInSec"));



or

<script language="javascript">
var TimeSec = Request.form("TimeInSec");



All three seems not working. Any workaround ? Thanks.

Regards,
Magix
 
M

Martin Honnen

magix said:
All three seems not working. Any workaround ? Thanks.

What exactly are you trying to achieve? Do you want to use JScript on
the server in classic ASP? Or JScript.NET with ASP.NET? Or something else?
 
M

magix

For example, there are 2 files, file1.asp and file2.asp
in File1.asp, i have
<form name="abc" method="post" action="file2.asp">

loop through some Db table record, and assign the value, like
<input type="hidden" name="QTimeInSec" value="<%=QTimeInSec%>">
</form>
after SUBMIT the form,
in File2.asp, i need to assign the value of request.form("TimeInSec") to
javascript variables for some further actions.
So, just wonder on how to apply the usage of Request.Form in javascript.

<script language="javascript">
var TimeSec = new string (request.form("TimeInSec"));
...
...
</script>
 
M

Martin Honnen

magix said:
For example, there are 2 files, file1.asp and file2.asp
in File1.asp, i have
<form name="abc" method="post" action="file2.asp">

loop through some Db table record, and assign the value, like
<input type="hidden" name="QTimeInSec" value="<%=QTimeInSec%>">
</form>
after SUBMIT the form,
in File2.asp, i need to assign the value of request.form("TimeInSec") to
javascript variables for some further actions.
So, just wonder on how to apply the usage of Request.Form in javascript.

<script language="javascript">
var TimeSec = new string (request.form("TimeInSec"));
...
...
</script>

Do you want to use JScript on the server instead of VBScript? Or do you
use VBScript in your ASP pages and want to pass values to client-side
JavaScript?
 
M

magix

I just want to pass the parameter value to javascript in another asp file.

Question is how's the usage of Request.Form in javascript ? Or is it
possible to use Request.Form in javascript

Regards.
 
E

Evertjan.

magix wrote on 22 dec 2007 in comp.lang.javascript:
<script language="javascript">
var TimeSec = new string (request.form("TimeInSec"));
...
...
</script>

You are mixing serverside code,
ASP-vbscript or ASP-j[ava]script,
with clientside Javascript.

That is imposible as the two interpreters run on seperate machines
and not even at the same time.
Serverside coding renders a stream of HTML [+ clientside scripts]
that are sent to the client, read browser.

ASP Request.form() returns a string if it exists.


So try this:

<script language="javascript">
var s = '<% = request.form("v1") %>'; // posting a string
var n = <% = request.form("v2") %>; // posting a number
</script>

The string should not contain '-s
 
T

Thomas 'PointedEars' Lahn

magix said:
For example, there are 2 files, file1.asp and file2.asp
in File1.asp, i have
<form name="abc" method="post" action="file2.asp">

loop through some Db table record, and assign the value, like
<input type="hidden" name="QTimeInSec" value="<%=QTimeInSec%>">
</form>
after SUBMIT the form,
in File2.asp, i need to assign the value of request.form("TimeInSec") to
javascript variables for some further actions.

<script type="text/javascript">
var timeSec = <%= Request.Form("TimeInSec") %>;
</script>

This is not really a J(ava)Script issue, but it is about understanding how
ASP(.NET) works (which is off-topic here).


PointedEars
 
M

magix

Thanks Evertjan. This works well.
Evertjan. said:
magix wrote on 22 dec 2007 in comp.lang.javascript:
<script language="javascript">
var TimeSec = new string (request.form("TimeInSec"));
...
...
</script>

You are mixing serverside code,
ASP-vbscript or ASP-j[ava]script,
with clientside Javascript.

That is imposible as the two interpreters run on seperate machines
and not even at the same time.
Serverside coding renders a stream of HTML [+ clientside scripts]
that are sent to the client, read browser.

ASP Request.form() returns a string if it exists.


So try this:

<script language="javascript">
var s = '<% = request.form("v1") %>'; // posting a string
var n = <% = request.form("v2") %>; // posting a number
</script>

The string should not contain '-s
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top