Click to See Complete Forum and Search --> : ASP: Assigning a JS value to an ASP Vairable


cancer10
08-27-2008, 08:14 AM
Hey PPL,

Came up with another issue.

If you were to fetch a value from js and store it in an asp variable, how would you do it?

I tried the following but it didn't worked. Any idea why?

<%
myStr = "<script>document.form1.txtName.value</script>"
response.write myStr
%>


Thnx

Kuriyama
08-28-2008, 03:16 PM
You can't write a javascript value into an ASP variable.

Javascript is executed after ASP.

Bullschmidt
09-07-2008, 06:21 PM
And it's a little convoluted but to see a JavaScript value in ASP you could have JavaScript put a value into a form field (possibly hidden) and then submit the form and then of course on the page receiving the post you could access that value in ASP with something like this:

MyVar = Request.Form("MyHiddenField")