Forum Moderators: open

Message Too Old, No Replies

jquery question:select change

         

php_member

6:29 pm on Jun 1, 2009 (gmt 0)

10+ Year Member



I hope I am not asking for too big favour. I would like to know how would be the code for the following:

When user choose select One, one.php appears inside div with id=include. If user select two, then two.php appears there. Inside those two files are some text and choose fields, but that doesn't matter, I just want to include it there.

<form>
<select id="test" name="testname">
<option value=1>One</option>
<option value=2>Two</option>
</select>
<div id="include">
</div>
</form>

Please at least just give me an idea what to look for to make this code.

Thank you very much

Damage

11:54 am on Jun 2, 2009 (gmt 0)

10+ Year Member



In the onChange event of your "select" tag, you need to add something like:

---------- Beginning of Code ----------

if (this.options[this.selectedIndex].value == 1)
{
$('#include').load('/one.php');
}
else
{
$('#include').load('/two.php');
}

---------- End of Code ----------

Hope this helps :-)