Howdy,
I'm trying to delete options based on a substring of their value but my code will only delete the first option and no others even though they match the substring.
The list in the select box will be dynamic so I can't always say "delete the first three options." I can control the value of the prog2 box so I'm making the first two characters be something I can use to determine what to delete.
Any ideas what I'm missing in getting the function to match to the other AO options so they can be deleted? Thanks! Lori
HTML:
Javascript:
I'm trying to delete options based on a substring of their value but my code will only delete the first option and no others even though they match the substring.
The list in the select box will be dynamic so I can't always say "delete the first three options." I can control the value of the prog2 box so I'm making the first two characters be something I can use to determine what to delete.
Any ideas what I'm missing in getting the function to match to the other AO options so they can be deleted? Thanks! Lori
HTML:
Code:
<td><label for="prog2" name="prog1" id="prog1">Program Code:</label></br>
<select name="prog2" id="prog2" multiple size="5">
<option value="ALL" selected="selected">ALL</option>
<option value="A0101">A0 - 101 - Regular Term Instruction</option>
<option value="A0102">A0 - 102 - Summer Term Instruction</option>
<option value="A0103">A0 - 103 - Extension Instruction/Non-Cred</option>
<option value="D0101">D0 - 101 - Regular Term Instruction</option>
<option value="D0110">D0 - 110 - Organized Research</option>
<option value="D0121">D0 - 121 - Administration</option>
<option value="M0990">M0 - 990 - Multi-activity</option>
<option value="L0110">L0 - 110 - Organized Research</option>
<option value="L0152">L0 - 152 - General Academic Support</option>
<option value="L0230">L0 - 230 - Student Financial Aid</option>
<option value="L0990">L0 - 990 - Multi-activity</option>
</select></td>
Javascript:
Code:
function updateProgList()
{
var progElement = document.getElementsByTagName('select')['prog2'];
// AO is hard-coded for now; later it will be read in from another
// select box to determine which values to delete from this box.
for ( var i = 0; i < progElement.length; i++ )
{ if ( progElement[i].value.substring(0,2) == 'A0' )
{ progElement.removeChild(progElement[i]);
}
}
}