...

View Full Version : Passing Variable



New4JsnVb
01-22-2005, 04:14 AM
Can Someone please help me how to pass jscript(str variable) to asp (strvar).

<Script>
function cmbSelect()
{
var w = document.log.Combo.selectedIndex;
var str = document.log.Combo.options[w].text;
}
</Script>

I want the str variable to be
<%strVal = str %> ------------------ This is code gives me error. Can you help me with this. Thank You.

sonal
01-22-2005, 10:31 AM
i am not sure means i have not try but may be poosible with

request.form() object.

if this will run than replay me......


:thumbsup:

sonal
01-22-2005, 10:43 AM
Hey first tell are you want this value without refreshing your page???????

if yes than its possible using request.form() object.

if no than you have to make array of javascript using asp at onload
example:
response.write("<script>")
response.write("var a")
response.write("a="&abc)
response.write("</script>")
here abc is asp variable of which u want value.

sonal is here..... :thumbsup:

New4JsnVb
01-23-2005, 03:04 AM
Thank you sonal. i tried what you gave me but still it didnt work. I will aprreciate anybody who could help me with this. Thank you in advanced.

ghell
01-25-2005, 01:34 PM
errm... to pass a client side variable to a server side variable you need to send the variable as a form or querystring element, then read it on the serverside, ie

<form name="f" method="post">
<input type="hidden" value="" name="str">
</form>

then either use a submit button on the form (in which case the form doesnt need a name) or use a link that runs document.f.submit()

this can then be read when the page reloads with Request.Form("str")

unrelated:

response.write("<script>")
response.write("var a")
response.write("a="&abc)
response.write("</script>")
ps, you dont need parenthesis in the Response.Write unles u are using ye olde asp, and you dont need to write each line on a separate line of asp, you need one on each line of javacript however (well you wouldnt if semicolon worked the way it does in java, and how its sposed to in javascript :p *shakes fist at the air*)

abc = "blah"
Response.Write "<script>" & vbNewLine & "var a = " & abc & ";" & vbNewLine & "</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum