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>

G5 dual, Mac OS X (10.4.9)

Posted on Jun 19, 2007 8:39 PM

Reply
2 replies

Jun 23, 2007 10:43 PM in response to DBering

Hi

the test page works fine in a very recent nightly build of Webkit ( the system framework behind Safari ) & Safari 2.0.4

I'm still on 10.4.9, so it's possible that 10.4.10 might fix it anyway.


..... since webkit fixes it, it's likely a bug that's been cured.

However, that doesn't help you get it working in older versions; you may get more help in the web-dev list at http://lists.apple.com/mailman/listinfo

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Javascript dynamic drop down not working in Safari

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.