Select the textfield and focus : TextField « Form Control « JavaScript DHTML
- JavaScript DHTML
- Form Control
- TextField
Select the textfield and focus
<html>
<head>
<script type="text/javascript">
function setfocus(){
document.forms[0].txt.select()
document.forms[0].txt.focus()
}
</script>
</head>
<body>
<form>
<input type="text" name="txt" size="30" value="Hello World!">
<input type="button" value="Select text" onclick="setfocus()">
</form>
</body>
</html>
Related examples in the same category