[thelist] please help - Javascript variables

Brian Delaney brian.delaney at mccmh.net
Tue Dec 21 14:30:20 CST 2004


Thanks you, I chose the option to write the input tag using javascript. 
That works great!

Matt Warden wrote:

>On Tue, 21 Dec 2004 14:24:38 -0500, Brian Delaney
><brian.delaney at mccmh.net> wrote:
>  
>
>>I am passing a window a javascript variable called myVar to a pop up window
>>
>>if I do something like alert(myVar) when the window loads it shows
>>correctly.
>>
>>I need to use the variable in asp though.  I have read that you can send
>>it using a hidden input type in a form.
>>
>>I have tried this:
>>
>><form name="frmLogin" ID="Form1">
>>  <input type="hidden" name="page" id="page" value="myVar">
>><etc. etc>
>>
>>When I  retrieve it and try a response.write in asp I get this: myVar -
>>so it's seeing the text only and not a variable.
>>
>>How do I pass the javascript variable myVar into the hidden Form? I have
>>tried value=<%myVar%>, value="javascript(myVar)" none work.
>>    
>>
>
>You want to set the form field to the value of myVar, so you need to
>do one of the following:
>
>1. keep the form tag like you have it, and do something like this:
><script type="text/javascript">
>window.onload = document.forms[0].elements['page'].value=myVar;
></script>
>
>Note that you might have to do this:
>window.onload = function() {document.forms[0].elements['page'].value=myVar;};
>
>2. Write your input tag using javascript:
><script type="text/javascript">
>document.writeln('<input type="hidden" name="page" value="'+ myVar +'">');
></script>
>
>
>hth,
>
>
>  
>

*
*
*
This message, including any attachments, is intended solely for the use of the named recipient(s) and may contain confidential and/or priveleged information.  Any unauthorized review, use, disclosure or distribution of this communication(s) is expressly prohibited.  If you are not the intended recipient, please contact the sender by reply e-mail and destroy any and all copies of the original message.


More information about the thelist mailing list