Hi All
I have 2 select boxes, what I need is the second select box to be populated dependent on the primary select box. Basically to put it in context, the primary select box will select the switch a computer is plugged into, which will then populate the secondary select with the free switch ports on the switch (from a database).
The code I have is:
<select id="switch1" name="switch[]" onchange="$('#switch_port1').load('/index.php?file=devices&action=misc_functions&mode=switchports&switch='+$(this).val() +' #switchports');" style='width:110px'>
<option value=''></option>
{PHP Generated list of switches}
</select>
Port:
<select id="switch_port1" name="switch_port[]" style='width:110px'>
<option value=''></option>
</select>
Now, the code at /index.php?file=devices&action=misc_functions&mode=switchports&switch=<number> returns a full page, which contains a div with id 'switchports'
When I run this, and change the switch1 select box, the switch_port1 select box doesn't change. I recently had this working using a completely seperate php page that simply generated the options, which did work, however, as this didn't go through the index.php page, it didn't go through the authentication of the user etc, so was not ideal.
Finding out that I can use:
$('#selector-to-fill').load('/path/to/file.html #fill-this')
I thought it would simply be a case of modifying the onchange event to the new location, and then setting up the new location to generate teh full code, however, this doesn't seem to work.
Looking at the code, it looks as though the returned file doesn't ahve the options set, and it's simply returning the "text" of the option, as I sometimes get simply one option, that is a list of all of the options all concatenated together. It's like it's not loading the sub-html of the div, and simply the text contained within.
If anyone has a solution to this, I would be much appreciative.