Drop Down Menu To Change PHP Variable?

Obsidian Age

New member
Hi there,

I've got a drop down menu that successfully updates a PHP variable when a submit button is clicked. However, I can find absoutely no working way whatsoever to get the submission to occur on selection of the variable from the drop down menu. I've tried things like:

OnChange="$variable=input.variable.
options[selectedIndex].value

to no avail. If someone knows of a solution it would be greatly appreciated!

Here is the working code with the submit button:

<html>
<body>
<form name="input" action="test.php" method="post" onchange="this.form.submit()">
<select name="variable" />
<option value="variable1">variable1</option>
<option value="variable2">variable2</option>
<option value="variable3">variable3</option>
<option value="variable4">variable4</option>
</select>
<input type="submit" value="Submit" />
</form>
</body>
</html>
<?php
if ($_POST['variable'] == '')
{
$variable = 'variable1';
}
else
{
$variable = $_POST['varibale'] ;
}
ADD: I changed the variable and option names as the actual table was originally for people I know. Thanks for pointing out the typo Web Programmer, but that doesn't fix the problem :(
ADD2: Thanks but that code creates a Submit button, as does my code posted initially. I need the drop down menu to change without having to click a button; just click on the varibale in the list.
 
Back
Top