Albert Pinto 0 Newbie Poster

Hi people, need some help...

I have a dropdown list with some options in it..
I have 2 buttons Select all and Reset.

What I want is, on click of Select All button, all the options inside it should get selected.

and Reset button should clear the entire form.

This is what I'm doing..

HTML Section:

<select name="alluser[]" id="alluser" size="6" style="width:300px" multiple="multiple">
while($row= mysql_fetch_array($result))
$address= $row['Email'];


<option><?php print_r($address); ?></option>



<input type="reset" value="Reset" class="resetto"> // this is my Reset button

<input type="button" value="Select All" class="selectto" onclick="selectall()">  // this is Select All button


function selectall(){

alluser.setAttribute("multiple", "multiple");
for (var i=0; i<alluser.options.length; i++)
alluser.options[i].setAttribute("selected", true);


PROBLEM IS: Of course when I open the page and click on the Select All....It selects all the values... But then If I click on any single option in the list... it will highlight that selected option, now if I click on Select All... It just won't Select All options...In fact my Reset Button starts acting as Select All button....
It selects all options on click...

Somewhat weird... isn't it...??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.