barkster Posted June 8, 2007 Share Posted June 8, 2007 Why doesn't this work in firefox? It works in IE and if I manually type in the 'ch1' it will change it but if I use the var it will not work in firefox. Thanks function deleterow(rvalue) { var answer = confirm("Are you sure you want to delete?"); var values = rvalue.split("|"); if(answer){ var chours = 'ch' + values[0]; var bhours = 'bh' + values[0]; alert(chours + "----" + bhours); document.getElementById(chours).innerHTML = "CH1" document.getElementById(bhours).innerHTML = "BH1" } else { alert(values[0] + '-' + values[1] + '-' + values[2] + '-' + values[3]); } } Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/ Share on other sites More sharing options...
lighton Posted June 9, 2007 Share Posted June 9, 2007 rows are read only in the DOM model to ue innerHTML in table rows you must use replaceChild. have a read of this http://developer.mozilla.org/en/docs/DOM:element.replaceChild Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-271375 Share on other sites More sharing options...
barkster Posted June 9, 2007 Author Share Posted June 9, 2007 Oh I'm sorry, that is just a function I'm calling to hide some text. It isn't really doing anything with a row. All this is doing is replacing some text in a span <span id="ch1">stuff</span><span id="bh1">stuff2</span> Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-271387 Share on other sites More sharing options...
barkster Posted June 9, 2007 Author Share Posted June 9, 2007 Also, the function worked if I don't use the var ch1 and hard code "ch1" into the getelementbyid I think the problem is coming from creating the control name dynamically Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-271397 Share on other sites More sharing options...
nicephotog Posted June 11, 2007 Share Posted June 11, 2007 eval( 'document.getElementById("'+chours+'")').innerHtml="CH1"; eval( 'document.getElementById("'+bhours+'")').innerHtml="BH1"; Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-272050 Share on other sites More sharing options...
barkster Posted June 11, 2007 Author Share Posted June 11, 2007 Ah, that makes perfect sense. For some reason it still won't work. Maybe it is something on my machine. No huge deals since it works in IE and will be deployed on IE platforms but I like to develop for firefox cause you know it will work in just about anything if you do. Thanks Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-272286 Share on other sites More sharing options...
barkster Posted June 11, 2007 Author Share Posted June 11, 2007 Well I can't get it to work in either IE or Firefox. Here is what I have stripped down. If you click on the first "delete row" link it should change the text in the div but will only do it with the hard coded values. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head><title> Time Report </title> <script language="javascript" type="text/javascript"> function deleterow(rvalue) { var answer = confirm("Are you sure you want to delete?"); var values = rvalue.split("|"); if(answer){ chours = "document.getElementById('ch"+values[0]+"').innerHtml=\"CH1\""; bhours = "document.getElementById('bh"+values[0]+"').innerHtml=\"CH1\""; alert(chours); eval(chours); eval(bhours); document.getElementById('ch2').innerHTML = "What a pain" document.getElementById('bh2').innerHTML = "in the Ass" } else { alert(values[0] + '-' + values[1] + '-' + values[2] + '-' + values[3]); } } </script> </head> <body> <div id="divRows"> <table width="700" order="0" cellspacing="0" cellpadding="0"><tr bgcolor="#FFE0C0" id="77581" style="display:block"> <td width="100%"><A HREF="javascript:deleterow('1|77581||8')">Click here delete entry</A></td> </tr><td background="images/line.gif"><img src="images/spacer.gif" width="1" height="1"></td></tr><tr bg="FFFFFF"><td align="right"><div id="ch1">Computer Hours: 0</div> <div id="bh1">Billable Hours: 8</div></td></tr><tr bgcolor="#FFFFFF" id="77582" style="display:block"><td><A HREF="javascript:deleterow('2|77582||8')">Click here delete entry</A></td></tr><td background="images/line.gif"><img src="images/spacer.gif" width="1" height="1"></td></tr><tr bg="FFE0C0"><td align="right"><div id="ch2">Computer Hours: 0</div> <div id="bh2">Billable Hours: 8</div></td></tr><tr bg="FFE0C0"><td> </td></tr></table> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-272380 Share on other sites More sharing options...
nogray Posted June 11, 2007 Share Posted June 11, 2007 Try this function function deleterow(rvalue) { var answer = confirm("Are you sure you want to delete?"); var values = rvalue.split("|"); if(answer){ document.getElementById('ch'+values[0]).innerHTML = "CH1"; document.getElementById('bh'+values[0]).innerHTML = "BH1"; } else { alert(values[0] + '-' + values[1] + '-' + values[2] + '-' + values[3]); } } Link to comment https://forums.phpfreaks.com/topic/54818-inner-html-firefox/#findComment-272404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.