Reputation: 859
I'm using a java script calendar date picker, my input fields and related java scripts are like below:
<input type="text" class="text date" maxlength="12" name="customerServiceAccountForm:fromDateInput" id="customerServiceAccountForm:fromDateInput">
<script type="text/javascript"><!--
document.body.onload = function(){
Calendar.setup({
inputField : 'customerServiceAccountForm:fromDateInput',
ifFormat : '%Y/%m/%d',
showsTime : false,
button : 'fromCalendar',
singleClick : true,
step : 1,
dateType : 'jalali',
range : [1300,1600]
});
}
//--></script>
<input type="text" class="text date" maxlength="12" name="customerServiceAccountForm:toDateInput" id="customerServiceAccountForm:toDateInput">
<script type="text/javascript"><!--
document.body.onload = function(){
Calendar.setup({
inputField : 'customerServiceAccountForm:toDateInput',
ifFormat : '%Y/%m/%d',
showsTime : false,
button : 'toCalendar',
singleClick : true,
step : 1,
dateType : 'jalali',
range : [1300,1600]
});
}
//--></script>
but when the page loads only the last date picker show up, what is the problem and how can I solve this problem. by the way this problem occurred after I surrounded the java script tags by a document.body.onload = function()
wrapper. What is going wrong with the date picker and how can I solve this thing?
Upvotes: 0
Views: 283
Reputation: 678
You can only have one body onload function. Instead create a single body onload function and add both calendars to it. Example...
function load(){
loadCalendar1();
loadCalendar2();
}
document.body.onload = load();
Also, I would move the javascript to a single script tag within the head tag of your html page, before the body tag.
Upvotes: 1