View Single Post
Old 09-26-2012, 12:37 AM   PM User | #11
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
See, instead of using innerHTML and then readjusting everything, you could do this:
Code:
    var tbl = document.getElementById("theTable");
    var newrow = tbl.insertRow(-1);

    var td0 = newrow.insertCell(-1);
    td0.className ="title"; 
    td0.appendChild( document.createTextNode( tbl.rows.length + ":" ) );

    var td1 = newrow.insertCell(-1);
    var inp1 = document.createElement("input");
    inp1.type="text";
    inp1.placeholder = "Giving";
    inp1.className = "selector";
    inp1.name = "giving" + tbl.rows.length;
    inp1.autocomplete = "off"; // ??? or false???
    td1.appendChild(inp1);

    var td2 = newrow.insertCell(-1);
    var inp2 = document.createElement("input");
    inp2.type="text";
    inp2.placeholder = "Getting";
    inp2.className = "selector";
    inp2.name = "getting" + tbl.rows.length;
    inp2.autocomplete = "off"; // ??? or false???
    td2.appendChild(inp2);

    var td3 = newrow.insertCell(-1);
    var inp3 = document.createElement("input");
    inp3.type="text";
    inp3.className = "popupdate";
    inp3.name = inp3.id = "popupdate" + tbl.rows.length;
    inp3.value = "when";
    ... code here to attach the calendar events to this element...
    td3.appendChild(inp3);
That really isn't that much code, and it's much clearner than using innerHTML.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
nick2price (09-26-2012)