Alter Select List

[Total: 0    Average: 0/5]

This shows how to update the label of a select list dynamically.

Body Code:

<script language="JavaScript">
<!--
  function updateItem() {
    var indexNum = parseInt(document.form1.myItem.value);
    var someText = document.form1.myText.value;
    document.form1.items[indexNum].text = someText;
  }
//-->
</script>

<form name="form1">
<select name="items" multiple>
<option>This is item no 1
<option>This is item no 2
<option>This is item no 3
</select>
<p>
I want item no <input name="myItem" type="text" size=3> to
be (any name)<input name="myText" type="text" size=30><p>
<input type="button" value="Update!" onClick="updateItem()">
</form>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *