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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

avoid similar value

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP
hi guys...
let say i have 2 listbox A and B. when the user select element from A and click ">>" button the element from A will be moved to A. My problem is some of A item may have the same value. i want to be able to check if the value of A is already in B list, display a message else put A value in B. How to do the checking. Now, my program will move the element regardless of the value.

Thanks for the help.
 
I have some similar code that moves text from one box to another. To check if something already exists I use:
Code:
//check to see if item is already in list 
//where tbox is to box and fbox is from box
j = 0;
while ((j < tbox.options.length) && (!(itemexists))) {
  if (tbox.options[j].value == fbox.options[i].value) {
    itemexists = true;
    if (tbox.name == &quot;list1&quot;){
      alert(fbox.options[i].text + &quot; already exists&quot;);
    }
  }
  j++;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top