Javascript dynamic drop down not working in Safari
This script works properly in windows IE, Firefox and mac Firefox, Camino, etc. but NOT in Safari. It controls a dynamic dropdown. Select the state 'Category' and the second dropdown 'metro' shows the city - in all browsers except Safari. For brevity, the example below shows only WY. When Category is selected, the Safari javascript console says:
"Value undefined (result of expression selectbox.options.add) is not object."
Is there anything I might be able to change so this will work in Safari? Thanks for any advice. Page is at http://look-on.com/ddTEST.html
--------------
<script type="text/javascript">
<!--
function SelectSubCat(){
removeAllOptions(document.form1.metro);
addOption(document.form1.metro,"00000", "Metro Area");
if(document.form1.Category.value == 'WY'){
addOption(document.form1.metro,"82601", "Casper");
addOption(document.form1.metro,"82001", "Cheyenne");
}
}
function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
function addOption(selectbox,value, text)
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
// -->
</script>
"Value undefined (result of expression selectbox.options.add) is not object."
Is there anything I might be able to change so this will work in Safari? Thanks for any advice. Page is at http://look-on.com/ddTEST.html
--------------
<script type="text/javascript">
<!--
function SelectSubCat(){
removeAllOptions(document.form1.metro);
addOption(document.form1.metro,"00000", "Metro Area");
if(document.form1.Category.value == 'WY'){
addOption(document.form1.metro,"82601", "Casper");
addOption(document.form1.metro,"82001", "Cheyenne");
}
}
function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
function addOption(selectbox,value, text)
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
// -->
</script>
G5 dual, Mac OS X (10.4.9)