This is a migrated thread and some comments may be shown as answers.
javascript to add number returned by combobox to date time
1 Answer 15 Views
This is a migrated thread and some comments may be shown as answers.
rahul
Top achievements
Rank 1
rahul asked on 18 Feb 2011, 03:35 PM
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

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Feb 2011, 10:10 AM
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
Asked by
rahul
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or