javascript to add number returned by combobox to date time

2 posts, 0 answers
  1. rahul
    rahul avatar
    2 posts
    Member since:
    Nov 2010

    Posted 18 Feb 2011 Link to this post

    i am facing lot of problem,i am returning number of days by combobox and i have to add into existing days,i did almost all conversion its return object type not supported by javascript,and in alert box while debugging its reurning objec,object.


    please help me out as i need this thing very soon
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 21 Feb 2011 Link to this post

    Hello Rahul,

    Try the following code:

    <%@ Page Language="C#" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <telerik:RadComboBox ID="DaysCombo" runat="server"
                OnClientSelectedIndexChanged="daysComboChanged">
                <Items>
                    <telerik:RadComboBoxItem Text=" " Value="0" />
                    <telerik:RadComboBoxItem Text="1 day" Value="1" />
                    <telerik:RadComboBoxItem Text="2 days" Value="2" />
                    <telerik:RadComboBoxItem Text="3 days" Value="3" />
                    <telerik:RadComboBoxItem Text="4 days" Value="4" />
                </Items>
            </telerik:RadComboBox>
             
            <telerik:RadDateTimePicker ID="Picker1" runat="server" SelectedDate="02/21/2011">
            </telerik:RadDateTimePicker>
     
            <script type="text/javascript">
                function daysComboChanged(sender, args)
                {
                    var days = +args.get_item().get_value();
                    var picker = $find('<%= Picker1.ClientID %>');
                    var date = new Date();
                    date.setDate(date.getDate() + days);
                    picker.set_selectedDate(date);
                }
            </script>
        </div>
        </form>
    </body>
    </html>

    Veli
    the Telerik team
Back to Top