开发者

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 ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜