Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

request variable?

Status
Not open for further replies.

derketa

Programmer
May 13, 2002
43
0
0
TR
Hi,
I need to redirect my page to itself on th onChange event of the select box with the value selected.I am using:

<script language="javascript" type="text/javascript">
function redirect(URLStr) { location = URLStr; }
</script>

....


<select name="select_project" id="select_project" onChange="javascript:redirect('add_pro_sv.php?sproject=this.value');">

How can i use this variable in my php code?
 
try this, and use the value of the option as your var.

Code:
<select onChange="if(this.options[this.selectedIndex].value.length>0){top.location.href=''add_pro_sv.php?sproject='+this.options[this.selectedIndex].value}">

hth

simon
 
I tried but did not work,it did not redirect also.
 
it did not work" ?

It does work, I would class user error as the problem.

providing javascript is enabled, which would also exclude ur code. This will redirect the page.

try this:

Code:
<select onChange="if(this.options[this.selectedIndex].value.length>0){top.location.href=''add_pro_sv.php?sproject='+this.options[this.selectedIndex].value}">
<option>** Select **</option>
<option value="testme">Test Me</option>
</select>


hth

simon

 

Simon,

Both versions of your code suffer from the same problem - double apostrophes directly after "top.location.href=".

Hope this solves the ''user error'' problem ;o)

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top