I'd fix up these two lines like this:
Code:
<td><input type="text" name="new_value"/></td>
<td><input type="button" onclick="addNewValue(this);" name="modify"/></td>
then you can add this function to do the work
Code:
function addNewValue(el) {
var list = el.form.elements["my_list"];
var entry = el.form.elements["new_value"];
var opt = document.createElement("option");
opt.value = entry.value;
opt.appendChild(document.createTextNode(entry.value));
// assuming you want "Other..." to remain the last element
var other = list.options[list.options.length - 1];
list.insertBefore(opt,other);
entry.value = "";
}
Bookmarks