admin管理员组文章数量:1022853
I've been trying to pass through JS variables via the onChange event but keep receiving the
Uncaught TypeError: Cannot read property 'firstChild' of null
under Google Chrome. Here is my code below:
artistID = album_select.substring(0, album_select.indexOf('/'));
albumID = album_select.substring(album_select.indexOf('/')+1, album_select.length);
var count = 0;
var tracklist = '';
for(track in albumlist[albumID][2]){
count++;
tracklist+="<option id='"+album+"'>"+track+"</option>";
}
hstr+="<form><select size='"+count+"' onChange='parent.loadSong(this.value, document.getElementById(\"album_select\").firstChild.nodeValue, document.getElementById(\"artistID\").firstChild.nodeValue)' style='font-size:2em;'>";
hstr+=tracklist;
hstr+="</form></select>";
I've been trying to pass through JS variables via the onChange event but keep receiving the
Uncaught TypeError: Cannot read property 'firstChild' of null
under Google Chrome. Here is my code below:
artistID = album_select.substring(0, album_select.indexOf('/'));
albumID = album_select.substring(album_select.indexOf('/')+1, album_select.length);
var count = 0;
var tracklist = '';
for(track in albumlist[albumID][2]){
count++;
tracklist+="<option id='"+album+"'>"+track+"</option>";
}
hstr+="<form><select size='"+count+"' onChange='parent.loadSong(this.value, document.getElementById(\"album_select\").firstChild.nodeValue, document.getElementById(\"artistID\").firstChild.nodeValue)' style='font-size:2em;'>";
hstr+=tracklist;
hstr+="</form></select>";
Share
Improve this question
asked Dec 3, 2011 at 23:13
methuselahmethuselah
13.2k53 gold badges177 silver badges333 bronze badges
1
- can u show the html for album_select and artistID please? – samach Commented Dec 3, 2011 at 23:30
1 Answer
Reset to default 1This part of the string:
document.getElementById(\"artistID\")
Is looking for an ID of "artistID"
.
I assume you meant to concatenate the variable.
"...document.getElementById('" + artistID + "')..."
Sounds like this one needs it too:
"...document.getElementById('" + album_select + "')..."
I've been trying to pass through JS variables via the onChange event but keep receiving the
Uncaught TypeError: Cannot read property 'firstChild' of null
under Google Chrome. Here is my code below:
artistID = album_select.substring(0, album_select.indexOf('/'));
albumID = album_select.substring(album_select.indexOf('/')+1, album_select.length);
var count = 0;
var tracklist = '';
for(track in albumlist[albumID][2]){
count++;
tracklist+="<option id='"+album+"'>"+track+"</option>";
}
hstr+="<form><select size='"+count+"' onChange='parent.loadSong(this.value, document.getElementById(\"album_select\").firstChild.nodeValue, document.getElementById(\"artistID\").firstChild.nodeValue)' style='font-size:2em;'>";
hstr+=tracklist;
hstr+="</form></select>";
I've been trying to pass through JS variables via the onChange event but keep receiving the
Uncaught TypeError: Cannot read property 'firstChild' of null
under Google Chrome. Here is my code below:
artistID = album_select.substring(0, album_select.indexOf('/'));
albumID = album_select.substring(album_select.indexOf('/')+1, album_select.length);
var count = 0;
var tracklist = '';
for(track in albumlist[albumID][2]){
count++;
tracklist+="<option id='"+album+"'>"+track+"</option>";
}
hstr+="<form><select size='"+count+"' onChange='parent.loadSong(this.value, document.getElementById(\"album_select\").firstChild.nodeValue, document.getElementById(\"artistID\").firstChild.nodeValue)' style='font-size:2em;'>";
hstr+=tracklist;
hstr+="</form></select>";
Share
Improve this question
asked Dec 3, 2011 at 23:13
methuselahmethuselah
13.2k53 gold badges177 silver badges333 bronze badges
1
- can u show the html for album_select and artistID please? – samach Commented Dec 3, 2011 at 23:30
1 Answer
Reset to default 1This part of the string:
document.getElementById(\"artistID\")
Is looking for an ID of "artistID"
.
I assume you meant to concatenate the variable.
"...document.getElementById('" + artistID + "')..."
Sounds like this one needs it too:
"...document.getElementById('" + album_select + "')..."
本文标签: javascriptUncaught TypeError Cannot read property 39firstChild39 of null error messageStack Overflow
版权声明:本文标题:javascript - Uncaught TypeError: Cannot read property 'firstChild' of null error message - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745569420a2156646.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论