General discussion


dhtml listbox question

By carolshafir ·
lets say i have a listbox on a web page, HTML that is. it would be as follows:
<select size=10>

now the point is when i click on and select the option don. i want to change its status in the list to 2nd. thus making the order mike,don,joe.

then if i run the logic again when don is selected i would like to have the list be don,mike,joe.

i would like to use the methods and properties of the listbox to do this. if it is possible.

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

dhtml listbox question

by wjhunt In reply to dhtml listbox question

This seems to work. Not sure if it is exactly what you want. You could probably set up some arrays to process more efficiently.

<script language='javascript'>

function rearnge() {
if (cat.cat1.value == 'Joe') { cat.cat1.options[0] = new Option('Mike','Mike');
cat.cat1.options[1] = new Option('Joe','Joe');
cat.cat1.options[2] = new Option('Don','Don');

} else
if (cat.cat1.value == 'Don') { cat.cat1.options[0] = new Option('Mike','Mike');
cat.cat1.options[1] = new Option('Don','Don');
cat.cat1.options[2] = new Option('Joe','Joe');


<body >
<form name='cat'>
<select size='3' name='cat1' onClick='rearnge()'>
<script language='javascript'>
cat.cat1.options[0] = new Option('Mike','Mike')
cat.cat1.options[1] = new Option('Don','Don')
cat.cat1.options[2] = new Option('Joe','Joe')




Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums