Validating multi view single select lists using Javascript
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhishek_Vijaygopal
Posted On:   Friday, January 2, 2004 03:29 AM

Hi,



I have a multiple options shown for a



I have tried document.form.listname.options[document.form.listname.selectedIndex].value, and this seems to work for single display dropdown, it does not work for this one. How do I access the values? Pls advise.



Cheers!


Vizier

Re: Validating multi view single select lists using Javascript

Posted By:   Anin_Mathen  
Posted On:   Friday, January 2, 2004 09:33 AM

Abhishek,


For Select objects that can have multiple selections (that is, the SELECT tag has the MULTIPLE attribute), the selectedIndex property is not very useful. In this case, it returns the index of the first selection. To find all the selected options, you have to loop and test each option individually. For example, to print a list of all selected options in a selection list named mySelect, you could use code such as this:

document.write("You've selected the following options:
")for (var i = 0; i < mySelect.options.length; i++)
{
if (mySelect.options[i].selected)
document.write(" mySelect.options[i].text
")
}


Hope this helps.

Re: Validating multi view single select lists using Javascript

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, January 2, 2004 09:25 AM

? are you missing the "multiple" attribute?

About | Sitemap | Contact