Adding and Deleting Menu Select Items

[Total: 0    Average: 0/5]

This example shows you how to add and delete items in a form select menu.

Head Code:

function add() {
var newitem=prompt("Add New List Item","");
document.form.list[document.form.list.length] = new Option(newitem, document.form.list.length);
function del() {
if (document.form.list.selectedIndex >= 0) {

Body Code:

<form name="form">
<select name="list" size="10">
<option>List Item #1
<option>List Item #2
<option>List Item #3
<option>List Item #4
<p><input type="button" value="Add" onClick="add()"> <input type="button" value="Del" onClick="del()">

Times Viewed: 4

Leave a Reply

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