0

trying to run a block of javascript that includes an innerhtml update to a <td> inside a cfwindow popup window after the html but the innerhtml line errors. if i replace the innerhtml with an alert line - the alertbox shows just fine so the javascript executes.

the page trying to run in the cfwindow pop up is as simple as:

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="ffffff">
<tr>
    <td>Current Total:</td>
    <td id="newtotal">27</td>
 </tr>
</table>

<script language="javascript">
    var myTest = "88";
    document.getElementById('newtotal').innerHTML = myTest;
</script>
Torsten
  • 29
  • 3
  • What are you putting in the alert box? – Dan Bracuk Sep 03 '15 at 18:27
  • i put the line alert(myTest); – Torsten Sep 03 '15 at 19:22
  • Try replacing myTest with document.getElementById('newtotal').value. – Dan Bracuk Sep 03 '15 at 19:33
  • 1
    Can you pls take a bit more time to ask your question coherently (using like correct spelling and grammar, some appropriate punctuation and stuff like that) and also provide a SSCCE which demonstrates the issue, as well as not leaving us hanging with "the innerhtml line errors" but neglecting to say what the error *actually is* (which you have to agree is fairly fundamental to your situation). Perhaps read this: http://www.catb.org/esr/faqs/smart-questions.html – Adam Cameron Sep 03 '15 at 19:35
  • my sincerest apologies - i did not realize half of what one types doesn't appear as intended. My english as a 2nd language classes did not teach me that and again I am so sorry for making you have to read my question. I dont mind if in the future you dont read any of my questions, as they most likely will also contain errors. I am sure your time Adam is much more valuable than helping me out. And for the rest, the error that appears is "Error processing JavaScript in markup for element wTask_body: [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]" – Torsten Sep 03 '15 at 19:53
  • Dan - tried the .value instead but it did not work either. Same error. I believe I need to use the .innerhtml somehow - to populate a table cell. – Torsten Sep 03 '15 at 20:03
  • I assume your javascript runs before the DOM in cfwindow is finished loading, a.k.a. `Uncaught TypeError: Cannot read property 'innerHTML' of null`? – Alex Sep 03 '15 at 20:15
  • does that mean I can't use innerHTML while the page is loading? I have a similar item that is on the page via an 'onClick' button that runs fine - but wanted to set the text in the cells with the same code when the cfwindow page loads initially. – Torsten Sep 03 '15 at 20:23
  • 1
    If you want text to appear when the page loads, why not simply put it there without javascript? – Dan Bracuk Sep 03 '15 at 22:48

0 Answers0