prova questo esempio
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it" xml:lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>options cancellabili</title>
<script type="text/javascript">
// <![CDATA[
function removeOption(id_select, indice) {
// restituisce true se la rimozione ha avuto successo, false altrimenti
if (document.getElementById(id_select)) {
var sel = document.getElementById(id_select);
if (indice <= sel.options.length) {
var opt = sel.options[--indice];
sel.removeChild(opt);
return true;
}
}
return false
}
// ]]>
</script>
</head>
<body>
<select id="lista" size="3">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<input type="button" value="cancella option 1" onclick="removeOption('lista', 1)" />
<input type="button" value="cancella option 2" onclick="removeOption('lista', 2)" />
<input type="button" value="cancella option 3" onclick="removeOption('lista', 3)" />
<body>
</html>
Ciao
-Fab-