Hey!
I'm trying to populate a second dropdown in a dynamic way based on a previs selected dropdown. However, I've managed to write get the page to reload when I choose anything in the dropdownbox but the chosen value isnt passed after reloading. I have register_globals turned off (and prefer to) and i'm using the GET function to submit the form. However when I try setting values in the URL I cant get it to work. Example: dropdown.php?area=1 still gives me a value in the dropdownbox with the default value. What am I doing wrong? Running on a LAMP server. Apache 2.2, php 5.3. Note: I found the php code here on the web wwich is suppose to help me pass the GET variable and select the option in the selectbox.
This is my code:
<html>
<head>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.area.options[form.area.options.selectedIndex].value;
self.location='dropdown.php?area=' + val ;
}
</script>
</head>
</body>
<? @$area=$HTTP_GET_VARS['area']; ?>
<form action="" method="get">
<select name="area" id="area" onchange="reload(this.form)">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</form>
</body>
</html>
Also, if this could be done with POST (or equivalent function) it would be even better.
Regards.