Forum Moderators: coopster

Message Too Old, No Replies

Php postback upon selecting a selection in <select>

         

AWSwS

4:25 pm on Aug 13, 2008 (gmt 0)

10+ Year Member



Sorry if this has been answered before i did do a search but that was too no avial unfortunatly.

basically i have a <select><option></option></select> set in which i populate them with information from mysql. not a problem.

my issue is, is there a way for the information to automatically post back upon selecting on of the options?
if so can it be done in just php? if not any links to the javascript to do it, i tend to avoid mixing in javascript don't ask me why.

gcarn

8:13 pm on Aug 13, 2008 (gmt 0)

10+ Year Member



To clairfy, your asking if you can "automatically post back upon selecting on of the options"
If I understand your question, you want to submit your form post upon selecting an option?

That sounds to me like something you will need javascript / Ajax to accomplish

elitebomber

8:19 pm on Aug 13, 2008 (gmt 0)

10+ Year Member



You need javascript.

<script type="text/javascript">
function doSomething(){
document.form1.submit();
}
</script>
<form id="form1" name="form1" method="post" action="">
<select name="menu" id="menu" onchange="doSomething()">
<option>item1</option>
</select>
</form>

When the user changes the value of the menu it will submit the form.

AWSwS

8:36 pm on Aug 13, 2008 (gmt 0)

10+ Year Member



Thanks that was exactly what i was looking for, now just to work out how to reference the fact its been posted back in php.

if it was a button click i could use $_POST['Submit'] but thats not working in this case.

once again thank you!

Edit: Found answer print_r($_POST); revealed that althought submit wasn't happening the name of the select box was.

Once again thank you for your help you've been a godsend!

[edited by: AWSwS at 8:50 pm (utc) on Aug. 13, 2008]