Question : Javascript function to add today's date

I have a checkbox (asp:checkbox) server control. Id like to place today's date in its text property
when I check it. It would be in the format of xx/xx/xxxx. Id like to use a Javascript function to do that.  thanks

Answer : Javascript function to add today's date

You pass this database date value to the JavaScript function as another argument and in the Javascript function set the input argument value when the checkbox is checked. Following is the working sample code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <asp:CheckBox ID="chkControl" runat="server" onclick=<%# "setValue(this, '"+DataBinder.Eval(Container.DataItem, "CONTACTDATE")+"');" %> Text='<%#DataBinder.Eval(Container.DataItem, "CONTACTDATE")%>' />
            </ItemTemplate>
        </asp:Repeater>

<script type="text/javascript" language="javascript">
    function setValue(chkControl, serverValue)
    {
        if(chkControl.checked)
        {
            //chkControl.nextSibling.innerHTML = 'checked';
            chkControl.nextSibling.innerHTML = serverValue;
        }
        else
        {
            chkControl.nextSibling.innerHTML = 'Unchecked';
        }
    }
</script>
Random Solutions  
 
programming4us programming4us