Hi all,
In my Struts2 application, I used Datetime picker, while entering fields of a form, focus need to be set when a user performs an action for date fields.
So, I need to set the focus using javascript in one or more date fields in the forms.
While setting focus to these date fields,it does not set the focus on the fields
this is the code fragment that i used in my application
sales.jsp:-
<s:datetimepicker id="shipdate%{#statusB.index}"
name="salesshipmentvoList[%{#statusB.index}].shipdate"
theme="simple" value="%{#B.shipdate}" required="true"
cssClass="LoginTextBox"></s:datetimepicker>
java application code:-
public
String salesShipment(){
setFocus("shipdate");
setFocusIndex("shipdate");
}
<script type="text/javascript">
function focusNextField(focus,focusIndex){
//focusIndex is the index of a list element of the date field
document.getElementById("shipdate"+focusIndex).focus();
}
</script>
the javascript fucntion is called as follows in sales.jsp
<body onload=focusNextField('<s:property value="focus"/>','<s:property value="focusIndex"/>')>
the above code had no effect on focusing the date field 'shipdate0' or 'shipdate1' and so on