Forum Moderators: open

Message Too Old, No Replies

How to automatically submit a form?

after user selects option from drop down menu

         

dougmcc1

11:34 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



How do you automatically submit a form when a user selects an option from the drop down menu? The value of the selection needs to be stored in a variable so it can be used by a PHP script.

Thanks.

dougmcc1

1:34 am on Sep 24, 2003 (gmt 0)

10+ Year Member



Got it.

<form name=ChangeForm action="script.php" method=POST>


<select name="field_to_change" size=1 onChange=\"ChangeForm.submit();\" >

<option SELECTED>Choose Field to Change</option>
<option value=name>Organization</option>
<option value=description>Description</option>
<option value=address>Address</option>
<option value=city>City</option>
<option value=state>State</option>
<option value=zip>Zip Code</option>
<option value=phone>Phone number</option>
<option value=webaddress>Website address</option>
</select>
</form>

The JavaScript automatically submits the form when a new option is clicked on and the contents of that option is stored in variable $field_to_change so it can be used in the script like this:
UPDATE table SET $field_to_change = '$the_change' WHERE username='$username' AND password='$password';

tedster

5:13 am on Sep 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks dougmcc1 - I'm sure you've just helped lots of people who will run into the same issue.