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 biv343 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 options

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all,
i do have a multiple option :

<SELECT NAME=&quot;display_list&quot; MULTIPLE style=&quot;HEIGHT: 87px; WIDTH: 115px&quot;>
<OPTION VALUE=&quot;Project start date&quot;>Project start date
<OPTION VALUE=&quot;Quote Status&quot;>Quote Status
<OPTION VALUE=&quot;Quote Closed Date&quot;>Quote Closed Date
<OPTION VALUE=&quot;Prj desc.&quot;>Prj desc.
<OPTION VALUE=&quot;BDD&quot;>BDD</OPTION>
</SELECT>

what i'd like is that when i click a button all the options become selected, what kind of function should i call from my button ? Best regards X-),
Elise
 
ok tyris,looks like you are working a lot in JS.
heres something i tried.
------------------------------------------------------------
<html>
<script>
function selectall()
{

for(var i=0;i<document.multiselect.display_list.length;i++)
{
document.multiselect.display_list.option.selected=true;
}
}
</script>
<body>
<form name=&quot;multiselect&quot;>
<SELECT NAME=&quot;display_list&quot; MULTIPLE style=&quot;HEIGHT: 87px; WIDTH: 115px&quot;>
<OPTION VALUE=&quot;Project start date&quot;>Project start date
<OPTION VALUE=&quot;Quote Status&quot;>Quote Status
<OPTION VALUE=&quot;Quote Closed Date&quot;>Quote Closed Date
<OPTION VALUE=&quot;Prj desc.&quot;>Prj desc.
<OPTION VALUE=&quot;BDD&quot;>BDD</OPTION>
</SELECT>
<p><input type=&quot;button&quot; value=&quot;Select All&quot; name=&quot;submit&quot; onClick=&quot;selectall()&quot;></p>
</form>
</html>



------------------------------------------------------------
 
hi a correction---
it should be options in the script code.
the function should be---
function selectall()
{

for(var i=0;i<document.multiselect.display_list.length;i++)
{
document.multiselect.display_list.options.selected=true;
}
}
</script>
 
hey i don't understand...when i try to type a square bracket this editor does not accept it!
the code is---
function selectall()
{

for(var i=0;i<document.multiselect.display_list.length;i++)
{
document.multiselect.display_list.options squareBracketOpen i squareBracketClose.selected=true;
}
}

 
The problem with square brackets is probably related to the TGML markup tags you can uses to specify html-like attributes to your message. Try putting (open-square-bracket)code(close-sequare-bracket) and (open-square-bracket)/code(close-sequare-bracket) around your code. Also use the &quot;Preview Post&quot; button to see if your code was interpreted correctly.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top