What I'm trying to do is to use a selection box, not by clicking a button, but by clicking an item in the selection box, I want the same page to be reloaded and according to which item is selected, display different things, but the following code I wrote cannot pass the value of $option that corresonding to what the user clicked. I want the initial value be "Book", if I remove the second line $option = "Book"; then there is even no reload of the page any more. I thought the line '$option = llist.options[llist.selectedIndex].value;' in the JavaScript function should change the value of $option, but it's not.
In MainPage.php:
<?
GLOBAL $option;
$option = "Book";
echo "<SCRIPT LANGUAGE=\"JavaScript\">
<!--
function jumpTo(llist)
{
$option = llist.options[llist.selectedIndex].value;
window.location.href = \"MainPage\";
}
// -->
</SCRIPT> ";
?>
....
<?
echo "<form action=\"Redirect.php\" method=\"post\" name=\"form3\" >";
echo "<select name=\"menu\" size=\"3\" onChange=\"jumpTo(this);\">";
echo "<option NAME=\"operation\" value=\"Book\">Book</option> ";
echo "<option NAME=\"operation\" value=\"Furniture\">Book 2</option>";
echo "<option NAME=\"operation\" value=\"E_device\">Book 3</option>";
echo "</select>";
if($option=="Book"):
echo "<h4> >>> select $option </h4>";
elseif($option=="Book 2"):
echo "<h4> >>> select $option </h4>";
elseif($option=="Book 3"):
echo "<h4> >>> select $option </h4>";
endif;
echo "<p>";
echo "<input type=\"submit\" name=\"submit\" value=\"Search\" align=\"MIDDLE\" >";
echo " </form> ";
?>
No matter which items (Book, Book 2, Book 3) I click , it always reload and display " >>> Book ", which is the intial value of $option. How could I modify the code in order to let the value of $option to change accordingly?
Thanks in advance.