Prev: Onload Form Focus
Next: Safari and Window.onload timing
From: magix on 22 Dec 2007 13:03 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. "Martin Honnen" <mahotrash(a)yahoo.de> wrote in message news:476d4fec$0$13108$9b4e6d93(a)newsspool2.arcor-online.net... > magix wrote: >> 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? > > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/
From: Evertjan. on 22 Dec 2007 13:05 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 -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
From: Thomas 'PointedEars' Lahn on 22 Dec 2007 13:34 magix wrote: > 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 -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
From: magix on 22 Dec 2007 13:41
Thanks Evertjan. This works well. "Evertjan." <exjxw.hannivoort(a)interxnl.net> wrote in message news:Xns9A0EC2427CA62eejj99(a)194.109.133.242... > 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 > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) |