[Javascript] Listbox

Dave Stoltz dstoltz at shh.org
Tue Feb 3 13:57:46 CST 2004


ON the same topic, how do I select ALL the items in the select box with a
function? This is what I have so far, but doesn't seem to work:

<script>
function selectall(){
	if (form1.mylist.options.length>0){
		var howmany = form1.mylist.options.length;
		for(count=1;count==howmany;count++)
		form1.mylist.options[count].selected=true;
	}
}
</script> 


Thanks!

-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Peter Brunone
Sent: Monday, February 02, 2004 4:50 PM
To: '[JavaScript List]'
Subject: RE: [Javascript] Listbox


var myListLength = myList.options.length;

If length is greater than zero, you have at least one item in the list.

-----Original Message-----
From: javascript-bounces at LaTech.edu On Behalf Of Dave Stoltz

If I have a listbox (not a dropdown) named "mylist", how can I test to see
if there are any values in the box? I need to test if it's empty or not.

Thanks!


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript





More information about the Javascript mailing list