I have an assignment for my php class. I have a drop down menu on my html page. When I select a value, i want it to send me to the php page and then be able to pull the selected value into the php page. I'm getting sent to the page fine, but I have no idea how to grab hold of that value. Can someone help me?
thanks
MikeHi, and welcome to HTMLForums!
What's this value, a form sent using the POST method, or a query string maybe? What's the HTML code you have?It is a form sent using the post method. Here is the code:
<form name="genre" action="dvd.php" method="post">
<select name = "dropdown" onChange="if(this.options[this.selectedIndex].value) top.location.href=http://www.htmlforums.com/archive/index.php/(this.options[this.selectedIndex].label)">
<option value = ""></option>
<option value = "action" label="dvd.php">Action</option>
<option value = "comedy" label="dvd.php">Comedy</option>
</select>
</form>
I have to send whatever option they select to a PHP page. Then in the PHP page I have to retrieve it somehow using $_POST[???]
Thanks
MikeWell, the select's name if dropdown... so you should use $_POST["dropdown"] label= is doing you no good.that's what I thought, but it's not working. I've tried everything I can think of.
thanks
MikeI'm using that label for the "onChange="if(this.options[this.selectedIndex].label) top.location.href=http://www.htmlforums.com/archive/index.php/(this.options[this.selectedIndex].label)" so that it will send me to the page when i select one of the options. I couldn't use value, cause I need each of the values to be different to be able to tell which option they picked.
Mikewhy couldn't you do this
<form name="genre" action="dvd.php" method="post">
<select name = "dropdown" onChange="if(this.options[this.selectedIndex].value) top.location.href=http://www.htmlforums.com/archive/index.php/dvd.php">
<option value = ""></option>
<option value = "action">Action</option>
<option value = "comedy">Comedy</option>
</select>
</form>
and using $_POST['dropdown'] should have worked. do you kow if you have register_globals off or on?
thanks
MikeHi, and welcome to HTMLForums!
What's this value, a form sent using the POST method, or a query string maybe? What's the HTML code you have?It is a form sent using the post method. Here is the code:
<form name="genre" action="dvd.php" method="post">
<select name = "dropdown" onChange="if(this.options[this.selectedIndex].value) top.location.href=http://www.htmlforums.com/archive/index.php/(this.options[this.selectedIndex].label)">
<option value = ""></option>
<option value = "action" label="dvd.php">Action</option>
<option value = "comedy" label="dvd.php">Comedy</option>
</select>
</form>
I have to send whatever option they select to a PHP page. Then in the PHP page I have to retrieve it somehow using $_POST[???]
Thanks
MikeWell, the select's name if dropdown... so you should use $_POST["dropdown"] label= is doing you no good.that's what I thought, but it's not working. I've tried everything I can think of.
thanks
MikeI'm using that label for the "onChange="if(this.options[this.selectedIndex].label) top.location.href=http://www.htmlforums.com/archive/index.php/(this.options[this.selectedIndex].label)" so that it will send me to the page when i select one of the options. I couldn't use value, cause I need each of the values to be different to be able to tell which option they picked.
Mikewhy couldn't you do this
<form name="genre" action="dvd.php" method="post">
<select name = "dropdown" onChange="if(this.options[this.selectedIndex].value) top.location.href=http://www.htmlforums.com/archive/index.php/dvd.php">
<option value = ""></option>
<option value = "action">Action</option>
<option value = "comedy">Comedy</option>
</select>
</form>
and using $_POST['dropdown'] should have worked. do you kow if you have register_globals off or on?