how do you resolve 'options' is null or not an object in Internet Explorer?
I am currently working on an issue with an e-commerce page that goes to a form to enter your information. The order process works fine but there is an annoying issue with Internet Explorer stating.... A Runtime Error has occured. Do you wish to Debug... Etc Error: 'options' is null or not an object. I looked at the code to debug and this is the particular problem area
function init_state_menu(country_field) {
var country_menu = document.getElementsByName(country_field)[0];
var country_id = country_menu.options[country_menu.selectedIndex].value;
generateStates(country_field, country_id);
}
I ran a test to see if the variable country_menu is defined and it states that is not defined. Any suggestions are appreciated. Thanks
Status:
Open Apr 09, 2008 - 09:57 AM
Errors, forms, testing, JavaScript
2answers
Answers
Jul 11, 2008 - 02:52 PM
if(typeof(window.external) != 'undefined'){
//yes, this is evil browser sniffing, but only IE has this bug
document.getElementsByName = function(name, tag){
if(!tag){
tag = '*';
}
var elems = document.getElementsByTagName(tag);
var res = []
for(var i=0;i att = elems[i].getAttribute('name');
if(att == name) {
res.push(elems[i]);
}
}
return res;
}
}
its from msdn forums
ps. tag is optional for this method, it will default to wildcard * if not specified (meaning it will check all elements in the document for given name)
Mar 04, 2009 - 06:07 AM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment