using javascript onchange to fill a calendar

Posted by scatman on Stack Overflow See other posts from Stack Overflow or by scatman
Published on 2010-04-14T06:48:38Z Indexed on 2010/04/14 6:53 UTC
Read the original article Hit count: 422

Filed under:
|
|

i have a calendar and a textbox in my c# asp.net application.
when a user enters a date in the textbox, the selected date in the calendar should become the date entered in the text box. the hard part is that i need to do this in javascript.
what i have now is this:

<asp:TextBox ID="txtDate" runat="server" onchange="javascript: Changed( this );"  />  
<asp:Calendar ID="calDate" runat="server" /> 

 <script type="text/javascript">
    var calendarID = '';
    function Changed(textControl) 
    {
        var date = Date.parse(textControl.value);  //this is giving me the date in seconds
        var cal = document.getElementById(calendarID);       
    }
</script>  

and i am setting calendarID in this way:

    <script type="text/javascript">
        calendarID = "<%=calDate.ClientID%>";
     </script> 

there is no cal.selectedDate or anything like this... any help?

© Stack Overflow or respective owner

Related posts about c#

Related posts about JavaScript