View Full Version : Passing Variable

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

function cmbSelect()
var w = document.log.Combo.selectedIndex;
var str = document.log.Combo.options[w].text;

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

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......


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
response.write("var a")
here abc is asp variable of which u want value.

sonal is here..... :thumbsup:

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.

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">

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")


response.write("var a")
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