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

Selecting Options In Drop Down Menu? 1

Status
Not open for further replies.

perlkid

Programmer
Mar 9, 2000
35
US


Say I have a form with this field, I'm testing with this.

<form method=&quot;POST&quot; name=&quot;form&quot; action=&quot;--WEBBOT-SELF--&quot;>
<p><select size=&quot;4&quot; name=&quot;list&quot; class=&quot;daf&quot;>
<option selected value=&quot;sfsdf&quot;>sfsdf</option>
<option value=&quot;s&quot;>asdfasdf</option>
<option value=&quot;asdfsadf &quot;>asdfsadf</option>
<option value=&quot;sadfasdf&quot;>sadfasdf</option>
<option value=&quot;asdfsadfsadf&quot;>asdfsadfsadf</option>
<option value=&quot;asdfsadfasdf&quot;>asdfsadfasdf</option>
<option value=&quot;ssadfsadf &quot;>ssadfsadf </option>
</select></p>
<p><input type=&quot;button&quot; onclick=&quot;highlight();&quot; value=&quot;Button&quot; name=&quot;B1&quot;></p>
</form>

I want all of the options in the box to highlight when you click on the button. I've tried everything my newbie mind could think of but I'm getting really frustrated and I ask for you help :)

Thanks A Lot,

Tony

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 
Do two things to make it work:

1. Set the select box to &quot;multiple&quot;:

<select size=&quot;4&quot; name=&quot;list&quot; class=&quot;daf&quot; multiple>

2. Paste the following script into your source:

<script language=&quot;Javascript&quot;>
function highlight() {

for(j=0; j < document.form.list.length; j++) {
document.form.list[j].selected=true;
}
}
</script>

Good luck and have fun :)

<webguru>iqof188</webguru>
 
Whoo HOO!!!!

Wow Mate Thanks A Million!!! You saved my day Mate!! :)

That was very nice of you. You got my vote :)

Tony

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top