How do i focus a input type="text" automatic when my id changes in page url ?
For example: http://mysite.php?id=2
I want to focus the mouse on my type="text" when my PHP IF statement is met without using buttons.<form>
&l开发者_StackOverflow中文版t;input type="text">
</form>
It should go something like: php IF (condition) { focus the mouse to input type="text" based on id of url }
You mean this:
<?php
if (intval($_GET['id']) === 1) // adjust value
{
?>
<script type="text/javascript">
// focus element
var el = document.getElementById('elem_id');
el.focus();
</script>
<?php } ?>
精彩评论