Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3 combo,1 field 1

Status
Not open for further replies.

biddingbong

IS-IT--Management
Sep 10, 2004
67
MU
Hi, Ive got 3 combobox on a page and they are all retrieving from the same field. The user will have the option of selecting from 1 to 3 products. But how can I populate all the three combo so that if the user select 1 product from one combo , the same product should not be in the 2nd combo, and selecting another product from the 2nd combo, the 3rd combo should not contain the products chosen in the first and the second combo. I really dont know how to do that.
Thanks.
 
If you can't use a MULTIPLE select field, then I will presume that your dropdowns all contain the same options in the same order. If so:

<select name="one" onchange="checkSelect(this.name);">
...
<select name="two" onchange="checkSelect(this.name);">
...
<select name="three" onchange="checkSelect(this.name);">

Then:

Code:
function checkSelect(name)
{
 var ind1 = document.formName.elements["one"].selectedIndex;
 var ind2 = document.formName.elements["two"].selectedIndex;
 var ind3 = document.formName.elements["three"].selectedIndex;
 if(ind1 == ind2 || ind1 == ind3 || ind2 == ind3)
  document.formName.elements[name].selectedIndex = -1;
}

If any of the three dropdowns match, then it is because of the one you just changed, so it sets the selectedIndex of that one to -1 (no selection).

'hope that helps.

--Dave
 
Finally I used the select multiple, but I tried LookForInfo's solution, and its something very interesting.
Thanks. And here's the sheriff sign.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top