Forum Moderators: open
Idea two: Okay, you're resolved to do this, look at window.onload:
window.onload=function() {
if (document.getElementById('qty1')) {
document.getElementById('qty1').focus();
}
};
You're getting an error because only body has loaded, qty1 has not yet loaded. You could also do, right before closing body tag,
<script type="text/javascript">
if (document.getElementById('qty1')) {
document.getElementById('qty1').focus();
}
</script>
</body>
</html>
Don't forget to add ID's to your form elements, which you should be doing anyway for proper labels.