Aaron said:
I want to make a form field take focus ideally coded in the form :-
<form method="post" action="index.php?action=newname">
<input type="text" name="name" size="40" value="" />
<input type="submit" name="submit" value="Create" />
</form>
This is how I'd do it, using JavaScript: (I know of no simple HTML solution)
1. Add a name to your form: <form name=myform method=...
2. Add the following to give focus to your "name" field:
<SCRIPT>document.myform.name.focus()</SCRIPT>
In place of "document" you can use "this" if you prefer, because your
script is inside the document, so "this" knows where to operate.
The [name] in the script is the ["name"] from your type="text" control;
nothing to do with the "name" in "name=" found in both your controls. So
if you'd used [name="person"] your script would be
document.myform.person.focus(). The references are case sensitive, so
neither "Myform" nor "Name" would work in your script.
I don't know if there are any rules on where the SCRIPT should go. I put
it just after the form, or even inside the form. Nothing (other than
some of the people around here!) seems to care.
The script itself conforms to the mathematical condition of "necessary
and sufficient". It contains everything that is necessary to make it
work, and nothing that exceeds what is sufficient to make it work.