Good morning all, Hi, I have a doubt. How can I pass a javascript value to a asp varible. Let me tell in brief, <script> var x = 2 </script> now I need to pass this variable value to a asp variable <% dim y y = [Here I need to bring that javascript variable value] %> Thanks in advance With regards Shaji
You would need to have the client side script assign the value to a form element or control (depending on if you are talking classic or .Net asp) like a hidden form input.
Hi, Thanks for your reply.. Could you give me more explanation with just an example please? with regards Shaji
you can send data with hidden fields. <INPUT id="myfield" type="hidden" value="something" runat="server">
Dude try the easiest way. Get the data on client side, save it to a cookie then retrieve it via ASP I use that type of things on www.mobile.am you might wanna look at the JavaScripts, later I retrieve the data in the cookie via ASP and show the site the way I need to
I hope that link will help you. http://forums.devshed.com/asp-programming-51/passing-asp-via-hidden-form-fields-51717.html
A lot depends on what the javascript that originally generates the value is doing. If it is simply a calculation on another input field then simply regenerate the value when the page is submitted, if this is not possible then an onclick or such script can be added to set the value of the calculated field to a hiddenfield on the form.
you could have javascript redirect to the same url but with a url querystring, then have ASP read the querystring variable that javascript redirected with.
you can do it in two ways 1. If you want to pass the value from the script to other page, then put the value in the query string and get from other page. like this <script> var x = 2 form.Post(index.asp?val=) </script> <% dim y y = Request.QueryString(val) %> you can get the value by this, 2.. The second method is ... put the value in a hidden control. like form.HidControl.value = 2; and get the value from that control...