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

Select all the items in a list

Status
Not open for further replies.

gameon

Programmer
Feb 23, 2001
325
GB
Hi I have a list:

<select name=&quot;SelectedChannel&quot;>
<option value=&quot;1&quot;>One</option>
<option value=&quot;2&quot;>Two</option>
<option value=&quot;3&quot;>Three</option>
</select>

I know that I call tell it to select a certain option with:
document.FormName.SelectedChannel.selectedIndex =1;

But, how can I have a script that selects every option, regardless of the number of options?

Cheers,

M@)
 
Try this:
<html>
<head>
<script>
function selectAll(){
s=document.f.s;
for(var i=0;i<s.options.length;i++){
s.options.selected=true;
}
}
</script>
</head>
<body>
<form name=&quot;f&quot;>
<select name=&quot;s&quot; multiple size=&quot;3&quot;>
<option>a
<option>b
<option>c
</select>
<input type=&quot;button&quot; value=&quot;Select All&quot; onclick=&quot;selectAll()&quot;>

Adam

while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
Cheers Guys, Like the sig too.

Would like to see some comedy dirivitives too though...

M@)
 
Ok, how about this:
while(woman.style.visibility==null && wallet.value!=''){beer++;sight.blur()}

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top