<input type="button" onclick="insertBeforeSelected()" value="Insert option before selected" />
<html>
<head>
<script type="text/javascript">
function insertBeforeSelected()
{
var x=document.getElementById("mySelect");
if (x.selectedIndex>=0)
var y=document.createElement('option');
y.text='Kiwi';
var sel=x.options[x.selectedIndex];
try
x.add(y,sel); // standards compliant
}
catch(ex)
x.add(y,x.selectedIndex); // IE only
</script>
</head>
<body>