File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Multiselection without Ctrl,Shift keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Multiselection without Ctrl,Shift keys" Watch "Multiselection without Ctrl,Shift keys" New topic

Multiselection without Ctrl,Shift keys

Zosia Gargasaite

Joined: Nov 28, 2002
Posts: 1
How I can select a multiple items in a <Select multiple> tag but not use Ctrl, Shift or any keyboard keys. I want to use mouse left click only WITHOUT DRAGING. How I can prevent unselection for other already selected options?
In other words how to imitate Ctrl key on Select pulldown?
christoph weingarten
Ranch Hand

Joined: Oct 10, 2002
Posts: 39
i think there is no html-attribute to do so. but you could write a simple javascript-function. something like this would probably work:
function doSelect(itemNo) {
if (document.myForm.mySelection.options[itemNo].selected == true) {
document.myForm.mySelection.options[itemNo].selected = false;
} else {
document.myForm.mySelection.options[itemNo].selected = true; }
you have to call this function everytime the user clicks on an option.
i'm not sure, whether the code above runs. maybe you have to fix it a little bit
I agree. Here's the link:
subject: Multiselection without Ctrl,Shift keys
It's not a secret anymore!