All pastes #231937 Raw Edit

Something

public text v1 · immutable
·published 2006-11-01 03:33 UTC
rendered paste body
// I'm inserting a reminder in the <tr> tags here. Every 30 seconds this reminder gets updated. 
// The update is supposed to erase all the contents of the <tr> tags and place the new content in there instead.
// What actually happens though is that the reminder appends a newline every 30 secs. So after a few minutes, 
// I just get a page of blank rows with the text reminder pushed to the bottom....
     
HTML ...

<table class='info_table' id='reminders_box' ><tr></tr></table>

HTML AFTER DOM METHOD ... (onscreen this comes out as having many blank lines ... ???)

<table class="info_table" id="reminders_box">
  <tr id="reminder_id_114">
    <td align="left" width="20%">Tue 11:30</td>
    <td align="left" width="60%">sadfasdf</td>
    <td align="left" width="10%">2147483647</td>
    <td width="10%"><a onclick="kill_reminder(114)" href="#">Delete</a></td>
  </tr>
</table>

JS ...

          ...........building a new tr  (this is fine I think) ............

        rem_TR = document.createElement('tr');

        // go to remno first
        z = i +3 ;

        // give this a unique id so we can delete it
        rem_id='reminder_id_'+cols[z];
        rem_TR.setAttribute('id',rem_id);

        // create the tds
        rem_text_TD = document.createElement('td');
        rem_text_TD.setAttribute('align','left');
        rem_text_TD.setAttribute('width','20%');

        // reminder time attributes
        rem_time_TD = document.createElement('td');
        rem_time_TD.setAttribute('align','left');
        rem_time_TD.setAttribute('width','60%');

        // reminder sms attributes
        rem_sms_TD = document.createElement('td');
        rem_sms_TD.setAttribute('align','left');
        rem_sms_TD.setAttribute('width','10%');

        // delete is handled seperately
        rem_del_TD = document.createElement('td');
        rem_del_TD.setAttribute('width','10%');

        // insert the text elements
        rem_text_TD.appendChild(document.createTextNode(cols[i++]));
        rem_time_TD.appendChild(document.createTextNode(cols[i++]));
        rem_sms_TD.appendChild(document.createTextNode(cols[i++]));

        // create link and add properties
        rem_del_A = document.createElement('a');
        rem_del_A.setAttribute('href','#');
        rem_del_A.setAttribute('onclick','kill_reminder('+cols[i]+')');
        rem_del_A.appendChild(document.createTextNode('Delete'));
        rem_del_TD.appendChild(rem_del_A);

        // append the tds
        rem_TR.appendChild(rem_text_TD);
        rem_TR.appendChild(rem_time_TD);
        rem_TR.appendChild(rem_sms_TD);
        rem_TR.appendChild(rem_del_TD);


         ........... appending a tr (this is the problem)............

        // append the tr element ...
        // clear the node first
        document.getElementById('reminders_box').replaceChild(rem_TR,document.getElementById('reminders_box').firstChild);