Click to See Complete Forum and Search --> : selectedIndex


mili
10-28-2003, 08:12 AM
Hi,

If a select box contains only one value, I want that vale to be selected in the dropdown box, else I want to default the message "select from choices".How can I do this?

<select>
<option>Select from choices</option>
<option>London</option>
</select>

Thanks,
M

Khalid Ali
10-28-2003, 08:59 AM
you will reqire to write some javascript to ge this done.
Search the forums,there tonne of answers here explaining how to manipulate optiosn in a select box

pelegk1
10-28-2003, 09:08 AM
<select selectedindex=1 id="sel1">
<option>Select from choices</option>
<option>London</option>
</select>


or
<script>
if (document.sel1.length>1) {

document.sel1.selectedIndex=1;
}

</script>