How can I pass a variable set in Javascript to an ASP style variable?
Printable View
How can I pass a variable set in Javascript to an ASP style variable?
Hi parkes
if you mean sending the javascript variable to the same page in the same same hit, you can't as asp is completly server side and can't interact with client side scripting. but if you mean you just want to sen the variable to another asp page you could put it in the query string or in a hidden html field and post it off to the next page.
Hope this helps
Ian
Thanks that's what I thought and have been trying but for some reason it will not work:(
Here is the code any ideas?
<%
Response.write "<INPUT TYPE='button' NAME='view' VALUE='V' TITLE='View/Change full details' CLASS='btn2' onClick=""MM_goToURL('parent','companydet.asp?ID=" & Request.Form("companyref") & "&type=view&logid=" & sRef & "');return document.MM_returnValue"">"
%>
It doesn't pass 'companyref' across, though the value is set in the form field and I've even tried Request.Querystring and still no luck.
Is the field companyref in the same form as the button? In that case, what you're trying to do is impossible.
Request.Form("companyref") gets the value from the object companyref in the form posted to another page.
Try using Javascript instead (document.myform.companyref.value)