The order of javascript is important. I believe in your case you
haven't imported all the required dependencies before trying to call a
dojo function.
Try this:
Put: <s:head theme="ajax"/>
BEFORE you use the dojo-dependent javascript in the head.
If you only want to use the simple theme, then manually import all the required
dojo files using the code in head.ftl. (eg. you need dojoRequires.js among
others).
I suspect in your code below, dojo.addOnLoad(init) is throwing an exception and
this occurs before the javascript that loads the dependencies for the
datapicker can be executed (thus, none of the datepicker dependencies are
loaded).
It should look like this:
<head>
<s:head theme="simple"/>
<script language="javascript">
function calculateEndDate() {
startDate =
document.forms[0].elements['leasingStartDate.value'].value;
alert(startDate);
}
function init() {
var datePicker = dojo.widget.byId("leasingStartDate");
dojo.event.connect(datePicker, "onchange", calculateEndDate);
}
dojo.addOnLoad(init);
</script>
</head>
Take a look at the generated HTML and you'll understand what I mean.
Regards,
Jeromy Evans
Jugal wrote:
Hi Jeromy,
Thanks a lot for your reply. I am exatcly doing the same way as suggested by
you.. but now I am not able see the datetimepicker tag...
Here is the snippet of the code that I am using:
<head>
<script src="<%=request.getContextPath()%>/scripts/dojo.js"
type="text/javascript"></script>
<script language="javascript">
function calculateEndDate() {
startDate =
document.forms[0].elements['leasingStartDate.value'].value;
alert(startDate);
}
function init() {
var datePicker = dojo.widget.byId("leasingStartDate");
dojo.event.connect(datePicker, "onchange", calculateEndDate);
}
dojo.addOnLoad(init);
</script>
<s:head theme="simple"/>
</head>
<body style="margin-left: 31%; width: 388%;">
<s:form id="fm_form" action="requisition" theme="simple"
name="fm_form" method="POST">
<s:datetimepicker onchange="calculateEndDate()"
id="leasingStartDate"
displayFormat="dd.MM.yyyy" />
</s:form>
</body>
Kindly let me know what am I missing out here...
Thanks,
Jugal
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]