/    Sign up×
Community /Pin to ProfileBookmark

null or not an object error in IE works perfectly in Firefox

I have a method which works fine in FF, however in IE, I get a null or not an object error. Here is the code, IE complain about parameter lp which I pass value from another method.

[CODE]# function doLoadDictionary(word,lp,U){
# var X = !window.XMLHttpRequest ? new ActiveXObject(‘Microsoft.XMLHTTP’) : new XMLHttpRequest();
# X.open(‘GET’, U, true );
# X.onreadystatechange=function(){
# if (X.readyState == 4){
# if (X.status == 200) {
# if(U!=null){
# xmlDoc=X.responseXML;
# var eng = xmlDoc.getElementsByTagName(“english”);
# for(var i=0;i<eng.length;i++){
# if(word== eng[i].childNodes[0].nodeValue.toUpperCase()){
# slang = word;
# var lang = xmlDoc.getElementsByTagName(lp.toLowerCase());
# tlang = lang[i].childNodes[0].nodeValue;
# break;
# }
# }
# slang == undefined?(document.dictionary.english.value =”):(document.dictionary.english.value =slang);
# tlang == undefined?(document.dictionary.target.value =”):(document.dictionary.target.value =tlang);
# }
# }
# }
# }
# X.send(”);
# } [/CODE]

IE complains this line:
var lang = xmlDoc.getElementsByTagName(lp.toLowerCase()); that lp is null or not an object error.

Any help would be great. Thank you.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 01.2010 — what is[B] lp[/B]?
Copy linkTweet thisAlerts:
@Phoebe_SongauthorJul 01.2010 — lp is parameter I pass from another method. Here is the calling method.
[CODE]# function showDictionary(){
# var list = document.getElementById("dOption");
# var itemName= list.options[list.selectedIndex].value;
# var langPair = itemName.split("_");
# var sl = "English";
# var tl = langPair[1];
# switch (tl){
# case "ar-AR":
# tl = "Arabic";
# break;
# case "de-DE":
# tl = "German";
# break;
# case "es-ES":
# tl = "Spanish";
# break;
# case "fr-FR":
# tl = "French";
# break;
# case "it-IT":
# tl = "Italian";
# break;
# case "ja-JP":
# tl = "Japanese";
# break;
# case "pt-PT":
# tl = "Portuguese";
# break;
# case "ko-KR":
# tl = "Korean";
# break;
# case "ru-RU":
# tl ="Russian";
# break;
# case"zh-CN":
# tl = "Simplified_Chinese";
# break;
# case "zh-TW":
# tl = "Traditional_Chinese";
# break; }
# document.getElementById("sl").innerHTML = sl;
# document.getElementById("tl").innerHTML = tl;
# doLoadDictionary(this.words,tl,'city.xml');
# } [/CODE]


lp is a string, is the language name.
Copy linkTweet thisAlerts:
@Phoebe_SongauthorJul 01.2010 — I found the problem. It is this line in calling method.

var itemName= list.options[list.selectedIndex].value;

in IE it returns null.

What's IE way to get drop down list value?
Copy linkTweet thisAlerts:
@Declan1991Jul 01.2010 — You can do list.value. That selectedIndex was for older browsers.
Copy linkTweet thisAlerts:
@Phoebe_SongauthorJul 01.2010 — Actually I change value to text, then it works.

var itemName= list.options[list.selectedIndex].text
Copy linkTweet thisAlerts:
@Sterling_IsfineJul 01.2010 — I found the problem. It is this line in calling method.

var itemName= list.options[list.selectedIndex].value;

in IE it returns null.

What's IE way to get drop down list value?[/QUOTE]
Do your <option> elements have a marked-up [FONT="Courier New"]value[/FONT] attribute? They need to have.
×

Success!

Help @Phoebe_Song spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...