How do I ensure inserted date stays inserted until checked box is unchecked?
<p>Per this code below, when users check a box, date is automatically inserted into a textbox control called cDate. This works great:</p>

<pre><code>function ClickBox(cb) { 
    var tr = cb; 
    while (tr.tagName != "TR") { 
        tr = tr.parentNode; 
        if (tr == null) return; // something went wrong 
    } 
    var inps = tr.getElementsByTagName("input"); 
    for (var i = 0; i &lt; inps.length; ++i) { 
        var inp = inps[i]; 
        if (inp.name.indexOf("cDate") &gt;= 0) { 
            inp.value = rightDate(); 
            break; 
        } 
    } 
}
</code></pre>

<p>These are the affected controls:</p>

<pre><code>    &lt;ItemTemplate&gt; 
     &lt;asp:CheckBox ID="myrecord" runat="server" onclick="ClickBox(this)" /&gt; 
    &lt;/ItemTemplate&gt;  

   &lt;ItemTemplate&gt; 
    &lt;asp:TextBox runat="server" style="border: none;" ID="cDate"&gt;&lt;/asp:TextBox&gt; 
   &lt;/ItemTemplate&gt;
</code></pre>

<p>The issue users are currently having is that once a checkbox is checked and date is inserted, only way to remove the inserted dates is the click the Reset button.</p>

<p>They would prefer to have the inserted dates disappear once a checked box is unchecked.</p>

<p>This modified code below isn't working.  I am not getting any errors, however, whenever I am checking a box or unchecking it, nothing is happening - no date is getting inserted anymore.</p>

<pre><code>function ClickBox(cb) { 
        var tr = cb;
        var inps = tr.getElementsByTagName("input"); 
        if(cb.checked == 1){ // CheckBox checked condition 

                while (tr.tagName != "TR") { 
                        tr = tr.parentNode; 
                        if (tr == null) return; // something went wrong 
                } 
                for (var i = 0; i &lt; inps.length; ++i) { 
                        var inp = inps[i]; 
                        if (inp.name.indexOf("cDate") &gt;= 0) { 
                                inp.value = rightDate(); 
                                break; 
                        } 
                } 
        } 
        else{ 
                for (var i = 0; i &lt; inps.length; ++i) { 
                        var inp = inps[i]; 
                        inp.value = ''; 
                } 
        } 
}
</code></pre>

<p>I am not sure what I am doing wrong.</p>

<p>Thanks for your assistance.</p>
