Code that is not working
$(document).ready(function() {
if the action is successful and returns a success message then Only{
document.getElementById("tabledataid_row").focus();
}
});
Table data content
<table>
<tr>
<td id="tabledataid_row"></td>
</tr>
</table>
I want to put the focus back to a table data <td>
after the page has been submitted. For instance, in Struts action submit brings the form back to the top of the screen. I tried using the JavaScript method focus()
, it works fine with textfield or elements of input type.
But it is not working when I assign an id to the <td>
element and then pick it up in the form onload/document ready then call the focus() like this as above.
Please note that I have inserted tabindex at various places and this element id has tabindex 4. So, I dont want to change the tabindex to get the focus come to the id. Only the viewable page be shifted in such a manner that the required field gets visiable.