?
Solved

Multiselect Select Boxes without CTRL or Shift

Posted on 2003-03-07
3
Medium Priority
?
1,081 Views
Last Modified: 2007-12-19
Looking for a way to allow Multiselect
on a Select Box only using Mouse Clicks
on Items without having to Hold Down the
Shift or CTRL Keys.  Clicking on an item
would select it, clicking on an already
selected item would unselect it.  Was
wondering if any knows how this can be
done using Javascript?

0
Comment
Question by:iDude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 300 total points
ID: 8087326
Try this:

<html>
<head>
<script>
var selCtrl=new Array();
function reSelect(theSel){
 theIndex=theSel.selectedIndex;
 if(selCtrl[theIndex])
   selCtrl[theIndex]=false;
 else
   selCtrl[theIndex]=true;
 for(i=0;i<theSel.options.length;i++)
   if(selCtrl[i])
     theSel.options[i].selected=true;
   else
     theSel.options[i].selected=false;
}
</script>
</head>
<body>
<form>
<select name=mySel multiple
onClick="reSelect(this)">
<option>one
<option>two
<option>three
<option>four
<option>five
<option>six
</select>
</form>
</body>
</html>

Good luck,
Zvonko

0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10098195
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Zvonko {http:#8087326}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question