Sometimes you need to remove options from an HTML select list using Javascript. The following function can be called to remove options from a select list given the value of the relevant option.
The function requires two parameters. The first is the value of the option to remove and the second is the select list reference.
In order to get the correct reference you can use the following code :
myRef = document.getElementById('mySelectList');
<script language="JavaScript">
<!-- Begin
function SelectOptionRemove(pValue, pid)
{
// This function removes an option
// from an HTML select list
//
// pValue - Value of option to remove
// pID - select list to remove
//
// http://www.mattsbits.co.uk
var i;
var vLen;
// Get number of options in select list
vLen = pid.options.length;
// Loop through each option
for (i=0;i<vLen ;i++ )
{
// Look for match
if (pid.options[i].value == pValue)
{
// Remove option and exit loop
pid.options[i] = null;
break;
}
}
}
// End -->
</script>