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

ListBox selected item

Status
Not open for further replies.

logi2000

Programmer
Jun 17, 2003
221
CR
i need to know if any item from a list box has been selected. how can i do that.

the problem is that when i use this code:
wwid = document.CustomerSearch.elements.lstResults.value;

if the user has not selected any item from the listbox, it is giving me an error.
 
s=document.CustomerSearch.elements.lstResults;
wwid = s[s.selectedIndex].value;

Or if you just want to know if they selected something or not...

if(s.selectedIndex>-1){
alert('Something is selected!')
}

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top