View Full Version : onselect
ahmedsoliman
09-03-2002, 01:06 PM
i have dropdown box and i need if i select item, the page refreched by new querystring
whammy
09-03-2002, 05:28 PM
Sticking with server-side, you can just post the form and get the value of "blah" from the submission, and redirect to
"next.asp?BLAH=" & Request.Form("blah")
... which is the easiest way to do it. Or, you could do it with javascript if you aren't worried about people having it enabled (or you check for that):
Well, you can do it with javascript:
<script language="javascript"
type="text/javascript">
<!--
function getquerystring(that){
if(that){
document.qwerty.action = "next.asp?BLAH=" + that;
document.qwerty.submit();
}
else{
return false;
}
}
// -->
</script>
<form name="qwerty" method="post" action="next.asp" onsubmit="getquerystring(this.blah.options[this.blah.selectedIndex].value)">
<select name="blah">
<option value="ABC">ABC</option>
<option value="123">123</option>
</select>
</form>
I didn't test this code though.
:D
ahmedsoliman
09-04-2002, 09:57 AM
thank uou whammy, but please descripe the asp methode in deatail.
whammy
09-04-2002, 05:54 PM
I'm not sure what else I can explain(?)... if you want to get the value of a dropdown in ASP you have to submit the form.
Request.Form("variablename")
gets the posted variables from the form - so if your dropdown was named "blah" you could do:
blah = Request.Form("blah")
...
Response.Redirect("somepage.asp")
redirects to another page.
If you don't want to have to submit the form, you'll need to use javascript to do what you want (since no information is being sent to the server, ASP can't get it).
So you could use the example above, but instead of submitting the form just replace that stuff with
window.location = "next.asp?BLAH=" + blah
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.