I asked this once before (see this thread), but I’ve become stuck again, and that code does not seem to work in another example.
The GUI now has two different picklists. stylabid and pjtlabid. If I click on one of them, I want any selected items in the other list to get cleared.
Here is the jquery code:
$('input[name="stylabid"]').change(
function(){
$('#pjtlabid').find('option').prop('selected',false)
});
But this has no effect…does anyone see what’s wrong here?
TIA,
rixter
PS — Since some of you asked, here is the HTML code:
<div id=content-container2>
<fieldset>
<LEGEND><b>Select Study Sample</b></LEGEND>
<p>
<P CLASS=select_header>Study - Box - Well - Lab ID<br>
<SELECT multiple size=20 NAME="stylabid" onchange=show_stylabid() onclick=clear_fetch() STYLE="width: 115px">
<?php
$i=0;
while ($i < $numstylabids) {
$styarr = pg_fetch_row($stylabidresult);
echo "<option value=$styarr[0]>$styarr[1]\n";
$i++;
}
?>
</select>
</p>
</fieldset>
</div>
and the second select list:
<fieldset>
<LEGEND><b>Select Project Sample</b></LEGEND>
<p>
<P CLASS=select_header>Project - Box - Well - Lab ID<br>
<SELECT multiple size=20 NAME="pjtlabid" onchange=show_pjtlabid() onclick=clear_fetch() STYLE="width: 115px">
<?php
$j=0;
while ($j < $numpjtlabids) {
$pjtarr = pg_fetch_row($pjtlabidresult);
echo "<option value=$pjtarr[0]>$pjtarr[1]\n";
$j++;
}
?>
</select>
</p>
</fieldset>
If by picklist you mean a
<select>element, the problem is how you bind your change handler: a<select>is not an<input>. Instead, do:Also, be sure that you are using the right selectors;
'#pjtlabid'selects the element whose ID is pjtlabid, while[name="stylabid"]selects the element whose name is stylabid. The name and ID attributes are not the same.