javascript works in ie but not netscape

liunx

Guest
Hi everyone,<br />
<br />
My code works in IE but for some reason doesn't work in Netscape. I've been trying for quite a while and for some reason just can't get it to work. I've copied the code below, I would be so very grateful if someone could let me know what I need to change to get it to work with Netscape 7.1.<br />
<br />
Netscape javascript console gives an error- var sel = rows.cells[selColNo].children[0]; has no properties.<br />
<br />
Thanks!<br />
<br />
function fillAllSel(selAllIndex, selColNo) {<br />
if (selAllIndex > 0) {<br />
selAllIndex = selAllIndex - 1;<br />
<br />
var theTable = document.getElementById('dataTable');<br />
<br />
var rows = theTable.tBodies[0].rows;<br />
for (i = 0; i < rows.length; i++)<br />
{<br />
if (rows.cells[selColNo])<br />
{<br />
var sel = rows.cells[selColNo].children[0];<br />
if ((typeof(sel) != "undefined") && (sel.tagName == "SELECT"))<br />
{<br />
sel.selectedIndex = selAllIndex;<br />
sel.fireEvent("onchange");<br />
}<br />
}<br />
}<br />
<br />
// return the fill all to blank<br />
var selAll = document.getElementById('fillAllSelector');<br />
selAll.selectedIndex = 0;<br />
<br />
setChanged('1', '2');<br />
}<br />
}<!--content-->Is it possible that some of your JS keywords are IE proprietary (only designed and work for IE)?? Otherwise, I wouldn't know. I avoid JS as much as I can :) Perhaps you would get better results by posting in the JavaScript Section of this forum :)<!--content-->children is IE only.<br />
Have a look at PPK's children (<!-- m --><a class="postlink" href="http://www.xs4all.nl/~ppk/js/w3c/children.html">http://www.xs4all.nl/~ppk/js/w3c/children.html</a><!-- m -->)<br />
Try childNodes[] or item()<!--content-->Originally posted by Fang <br />
children is IE only.<br />
Have a look at PPK's children (<!-- m --><a class="postlink" href="http://www.xs4all.nl/~ppk/js/w3c/children.html">http://www.xs4all.nl/~ppk/js/w3c/children.html</a><!-- m -->)<br />
Try childNodes[] or item() <br />
<br />
I had a feeling, lol. Thank you, Fang, for clearing that up :) M$ just loves taking technologies that do not belong to them and make "advancements"' lol.<!--content-->Hi Guys,<br />
<br />
Thanks so much for the replies. I'm not sure what's up, but for some reason I still can't get it to work on Netscape 7.1 The same error keeps coming up-<br />
<br />
Netscape javascript console gives an error- var sel = rows.cells[selColNo].children[0]; has no properties. <br />
<br />
Even after I replace childNode with all the children in the scripts. <br />
<br />
Please let me know if there's anything I'm missing. And thanks again in advance!<br />
<br />
I'm posting the original code below:<br />
<br />
<br />
window.onload = init;<br />
<br />
function init() {<br />
var theSecSel = document.getElementById('selectedSectionId');<br />
var theBlkSel = document.getElementById('blockNumberSel');<br />
if (theBlkSel && theSecSel) {<br />
theBlkSel.selectedIndex = theSecSel.selectedIndex;<br />
}<br />
}<br />
<br />
<br />
/*<br />
function window.onbeforeunload() {<br />
<br />
<br />
var confirmed = true;<br />
if (changed) {<br />
var result = setDispatch("save");<br />
confirmed = confirm("You have unsaved changes. If you continue those changes will be saved? \nClick OK to save changes. \nClick CANCEL to stop.");<br />
<br />
result = result & confirmed;<br />
<br />
if (result) {<br />
<br />
document.forms[0].saveChanges.value = changed;<br />
document.forms[0].submit();<br />
}<br />
else {<br />
return "any string"<br />
}<br />
}<br />
}<br />
*/<br />
<br />
<br />
<br />
<br />
<br />
function syncSelecters(sel1, sel2, target) {<br />
if ((sel2.selectedIndex != sel1.selectedIndex)) { <br />
var result = setDispatch(target);<br />
var confirmed = true;<br />
if (changed) {<br />
confirmed = confirm("You have unsaved changes. If you continue those changes will be saved? \nClick OK to save changes. \nClick CANCEL to stop.");<br />
}<br />
result = result & confirmed;<br />
<br />
if (result) {<br />
document.forms[0].saveChanges.value = changed;<br />
sel2.selectedIndex = sel1.selectedIndex; <br />
document.forms[0].submit(); <br />
}<br />
else {<br />
sel1.selectedIndex = sel2.selectedIndex; <br />
}<br />
}<br />
}<br />
if(document.getElementById) { <br />
//DOM compliant browser <br />
} <br />
else if(document.all) { <br />
//old IE <br />
} <br />
else if(document.layers) { <br />
//NN4 <br />
} <br />
<br />
<br />
function fillAllSel(selAllIndex, selColNo) {<br />
if (selAllIndex > 0) {<br />
selAllIndex = selAllIndex - 1;<br />
<br />
var theTable = document.getElementById('dataTable');<br />
<br />
var rows = theTable.tBodies[0].rows;<br />
for (i = 0; i < rows.length; i++)<br />
{<br />
if (rows.cells[selColNo])<br />
{<br />
var sel = rows.cells[selColNo].children[0];<br />
if ((typeof(sel) != "undefined") && (sel.tagName == "SELECT"))<br />
{<br />
sel.selectedIndex = selAllIndex;<br />
sel.fireEvent("onchange");<br />
}<br />
}<br />
}<br />
<br />
// return the fill all to blank<br />
var selAll = document.getElementById('fillAllSelector');<br />
selAll.selectedIndex = 0;<br />
<br />
setChanged('1', '2');<br />
}<br />
}<br />
<br />
<br />
function fillAllText(textAll, textColNo) {<br />
var value = textAll.value;<br />
if (value.length > 0) {<br />
if (value == " ")<br />
value = "";<br />
<br />
var theTable = document.getElementById('dataTable');<br />
<br />
var rows = theTable.tBodies[0].rows;<br />
for (i = 0; i < rows.length; i++) {<br />
if (rows.cells[textColNo]) {<br />
var text = rows.cells[textColNo].children[0];<br />
if (<br />
(typeof(text) != "undefined") && <br />
(text.tagName == "INPUT") && <br />
(text.type == "text") &&<br />
!(text.disabled)<br />
) {<br />
text.value = value;<br />
}<br />
}<br />
}<br />
// return the fill all field to blank<br />
textAll.value = "";<br />
<br />
setChanged('1', '2');<br />
}<br />
}<br />
<br />
<br />
function setChanged(oldValue, newValue) {<br />
if (<br />
!((oldValue == "null") && (newValue == "")) &<br />
(newValue != oldValue) <br />
) {<br />
changed = true;<br />
}<br />
}<br />
<br />
<br />
function togglePortrait(check) {<br />
var result = confirmSubmit('togglePortrait');<br />
if (!result) {<br />
// if the user choose to cancel then toggle the check box back<br />
check.checked = !check.checked<br />
}<br />
return result;<br />
}<br />
<br />
<br />
<br />
<br />
function confirmSubmit(target) {<br />
var result = setDispatch(target);<br />
var confirmed = true;<br />
if (changed) {<br />
confirmed = confirm("You have unsaved changes. If you continue those changes will be saved? \nClick OK to save changes. \nClick CANCEL to stop.");<br />
}<br />
result = result & confirmed;<br />
<br />
if (result) {<br />
document.forms[0].saveChanges.value = changed;<br />
document.forms[0].submit();<br />
}<br />
return result;<br />
}<br />
<br />
<br />
</script><br />
<br> <a href=http://www.webdeveloper.com/forum/archive/index.php/"#" onclick="var frm = forms[0];<br />
if(frm){<br />
setDispatch('printPopulate');<br />
frm.submit();<br />
}<br />
<br />
<br />
return false;"> Printable version </a> <br> <br> </td><br />
</tr><br />
</tbody><br />
</table><br />
<br />
</td><br />
<br />
</tr> <br />
</tbody></table><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</td><br />
<br />
</tr><br />
</tbody></table><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</td><br />
</tr><br />
<br />
<br />
<tr><br />
<br />
<td colspan="2" align="left" valign="bottom"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table class="mainTable" cellpadding="0" cellspacing="0" width="100%" height="100%"><br />
<tbody><tr><br />
<br />
<td valign="top"><!--content-->Since we now know that 'children' is a Microsoft Proprietary, your best bet would be to check out some JS sites, ones that are not inclined to list M$ proprietary methods. Or, you could wait until FredMV comes online, he'll have an answer for this :)<!--content-->You should probably move this thread to the JavaScript Forum, as the moderators there will have an answer (FredMV is one of the moderators)<!--content-->Hi Guys,<br />
<br />
Thanks so much for the input. I've moved the thread to javascript... didn't know we had a separate place for it. <br />
<br />
Again, thanks so much for the assistance.<!--content-->no prob, glad we could help<!--content-->
 
Back
Top