This is a migrated thread and some comments may be shown as answers.

One Clear Function for multiple RadDatePickers

1 Answer 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 05 Mar 2013, 07:11 PM
Scenario: You have a start date picker and an end date picker and you want a function that will clear either based on passing the id.   While I know this works:

var StartDatePicker = $find("<%= dpStartDate.ClientID %>");
StartDatePicker.clear();

when we try to pass the id to a function something gets lost in the translation.  Is there any way to do something like:

function clearDatePicker(id) {
     var picker = $find(id);
     picker.clear();
}

called by:

<a href = "javascript: clearDatePicker('<%= dpStartDate.ClientID %.');">clear</a>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Mar 2013, 05:53 AM
Hello Shawn,

Please have a look at the following code that works fine at my end. Your issue is you are not giving the client id correctly to the function in the hyperlink (href="javascript:clearAll('<%=RadDatePicker1.ClientID %.')")

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
</telerik:RadDatePicker>
<br /><br />
<a href="javascript:clearAll('<%=RadDatePicker1.ClientID %>')">Clear All</a>

JavaScript:
<script type="text/javascript">
    function clearAll(id) {
        var picker = $find(id);
        picker.clear();
    }
</script>

Thanks,
Princy
Tags
General Discussions
Asked by
Shawn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or