Thursday, January 17, 2008

Helpful JavaScripts

To bring focus to a text box / button or any other element

just add this javascript in the HTML code:

<script type="text/javascript">
document.getElementById("elementId").focus();
</script>
where
elementId the id of the element on which the focus is to be set

for example, the following code will bring focus to the textbox that has the id email
<input type="text" id="email" />
<script type="text/javascript">
document.getElementById("email").focus();
</script>

No comments: