Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!

Bharath KumarG

Greenhorn
+ Follow
since Jun 13, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bharath KumarG

Hi Guys ,
I too googled for many hours for this and didnt find any solution, so i tried to do it myself and it worked out luckly

In my case i hve this datetimepicker in a TD
--------------------------------------------
<td onkeydown="Javascript:disablekeys();" onmousedown="Javascript:disableControls()">
<sx:datetimepicker id="startDate" name="startDate"></sx:datetimepicker>
</td>
--------------------------------------------

This is the outerHTML of the datetimepicker when it renders
-----------------------------------------------------------
This is document.getElementById('startDate').outerHTML;
<SPAN id=startDate>
<input type=hidden value=2009-06-11 name="" dojoAttachPoint="valueNode">
<input value=6/11/2009 name="" __doClobber__="true" dojoAttachPoint="inputNode">
<img alt="Select a date" src="../images/dateIcon.gif" __doClobber__="true" dojoAttachPoint="buttonNode" dojoAttachEvent="onclick:onIconClick">
---------------------------------------------------------------

So the solution i found out is
------------------------------
<script languae="javascript">
function disableControls(){
document.getElementById('startDate').childNodes[1].disable='true';
document.getElementById('startDate').childNodes[1].readOnly='readonly';
document.getElementById('startDate').childNodes[1].disable='';
}
function disableKeys(){
var keyCode=(document.all)?event.keyCode:e.which;
if(keyCode==9){
window.event.returnValue=true;
}else{
window.event.returnValue=false;
}
}
</script>
------------------------------

Note* -This will work unless and untill struts framework dont change the order of the childNode when rendering.

Thanks
Bharath
14 years ago