Link to home
Start Free TrialLog in
Avatar of HKFuey
HKFueyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Asp set focus on text box

I have this code: -
<html>
<head>
<meta name="GENERATOR" content="Microsoft Developer Studio"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Serials</title>
</head>
<body onload="setFocus('Dnote')" bgcolor="#CEE3F6" text="#000000">
<form name="Serial" action="Serials.asp" method="post">            
<table width="60%" border="0" align="left">  		
<tr><td width="10%"></td><td><input name="Add" type="submit" value="Update" onclick="setFocus('Dnote')"/></td></tr>
<tr><td width="50%"></td></tr>
	<tr><td width="10%"></td><td width="50%">Scan Dispatch Note Number</td></tr>
	<tr><td width="10%"></td><td><input name="Dnote" type="text" maxlength="30"  size="30"/></td></tr>
	<tr><td width="10%"></td><td width="50%">Scan Serial</td></tr>
    <tr><td width="10%"></td><td><input type="text" name="Serial" id="Serial" size="30"/></td></tr>
	<tr><td width="10%"></td><td width="50%"><%=iMsg%></td></tr>
</table>
</form>
</body>
</html>

Open in new window


On opening the page or pressing update I want the focus on 'Dnote'

Does anyone know how to do this?
Ps. KIS I'm new at this!
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Ok get rid of the body onload and place this script below your form.

<script type="text/javascript" language="JavaScript">
document.forms['Serial'].elements['Dnote'].focus();
</script>

Since submitting is the same as refreshing your page, this will work either way.
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HKFuey

ASKER

Thanks padas your first suggestion works great and thanks for the extra info!!