How to focus cursor on text box in php
How to focus cursor on text box in php. On error answer by user i want to focus the answer filed on load of page. so please suggest me...
if(isset($_REQUEST['sub_con_page']))
{
//correct
}
else
{
**//开发者_JAVA技巧focus field**
}
Do this in javascript. if you use jquery then
$("input[type=text]:first").focus();
You can do that by adding javascript/jquery code inside the else part of the statement:
if(isset($_REQUEST['sub_con_page']))
{
//correct
}
else
{ ?>
<script type="text/javascript">
$(document).ready(function() {
$("#ID_OF_TEXT_AREA_TO_FOCUS_HERE").focus();
});
</script>
<?php } ?>
Enjoy ;)
精彩评论