Question

  Asked: Apr 4 2008   12:47 AM GMT
  Asked by: Nimamuth


Multiple select


ComboBox, Select object, JavaScript, Development

My application has a screen with a multiple select object. I have javascript that dynamically selects items in the object based on user input. My question is: how can I force the select object to show the first selected object in the select object's display window. I've been successful with a select box that allows only one selection but cannot seem to do it with a multiple select box. I've included an example below where item 5 is selected. The selected item does not show in the select box's window though and I don't know how to force it. Thanks for any help.

<select name="selectme" multiple size="3">
<option>dog
<option>cat
<option>giraffe
<option>elephant
<option selected>tiger
</select>

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



Hello Nimamuth,

the code below works as desired.


<html>
<head>
<SCRIPT>
function scrollToLast(select) {
select.multiple=true;
}
</SCRIPT>
</head>
<body>
<select id="selectme" multiple="multiple" size="3" onload="scrollToLast(this)">
<option>dog</option>
<option>cat</option>
<option>giraffe</option>
<option>elephant</option>
<option selected="selected">tiger</option>
</select>
</body>
</html>
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Development.

Looking for relevant Development Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register