I'm trying to keep the selected / displayed option of two different
select lists synchronized -- so when the user selects, say, the third
option on one of them, the third option on the other is displayed:
Here's the code I'm trying -- but that doesn't seem to work:
function synchronizeSele cts(thisSelect, otherSelect)
{
// find the selected option in thisSelect
i = 0;
while(i < thisSelect.opti ons.length &&
!(thisSelect.op tions[i].selected))
i++;
// if there is one, and it's not greater in # than
// the number of options in the otherSelect
if( (i != thisSelect.opti ons.length)
&& (i < otherSelect.opt ions.length) )
{
//then search the otherSelect for a selction
//and turn it off
for(j = 0; j < otherSelect.opt ions.length; j++)
{
otherSelect.opt ions[j].select = false;
otherSelect.opt ions[i].defaultSelecte d = false;
}
//and then select i
otherSelect.opt ions[i].select = true;
otherSelect.opt ions[i].defaultSelecte d = true;
}
}
It's called from an onchange even on both selects. For example:
<select name="product" id="prod" class="smallsel ects"
onchange="synch ronizeSelects(t his,document.ge tElementById('s upp'))">
Any ideas what I may be doing wrong here?
Thanks,
Weston
~==~
Taking Pictures During Dreams
weston8[at]cann8central.or g
(remove eights to email me)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
select lists synchronized -- so when the user selects, say, the third
option on one of them, the third option on the other is displayed:
Here's the code I'm trying -- but that doesn't seem to work:
function synchronizeSele cts(thisSelect, otherSelect)
{
// find the selected option in thisSelect
i = 0;
while(i < thisSelect.opti ons.length &&
!(thisSelect.op tions[i].selected))
i++;
// if there is one, and it's not greater in # than
// the number of options in the otherSelect
if( (i != thisSelect.opti ons.length)
&& (i < otherSelect.opt ions.length) )
{
//then search the otherSelect for a selction
//and turn it off
for(j = 0; j < otherSelect.opt ions.length; j++)
{
otherSelect.opt ions[j].select = false;
otherSelect.opt ions[i].defaultSelecte d = false;
}
//and then select i
otherSelect.opt ions[i].select = true;
otherSelect.opt ions[i].defaultSelecte d = true;
}
}
It's called from an onchange even on both selects. For example:
<select name="product" id="prod" class="smallsel ects"
onchange="synch ronizeSelects(t his,document.ge tElementById('s upp'))">
Any ideas what I may be doing wrong here?
Thanks,
Weston
~==~
Taking Pictures During Dreams
weston8[at]cann8central.or g
(remove eights to email me)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Comment