|
HTML Tip:
Beware Of Misplaced INPUT Tags
by Tom Dahm,
Chief Operations Officer,
NetMechanic, Inc.
Unlike most traditional communications media, the Internet lets you receive instant feedback from your audience. Forms are one of the most common ways to send information. A click on the ubiquitous "Submit" or "Send it!" button initiates the submit process to send information to the server.
If the Submit button on your form isn't properly placed within the FORM tag, the form won't send properly. Don't let a simple HTML error deprive you of valuable feedback from visitors or even online orders from customers.
An Easy Mistake That's Hard To Find
If you use a WYSIWYG HTML editor such as Front Page, you probably won't find this problem until you actually begin to test your form in a browser. The following code displays perfectly in some editors' preview options even though the INPUT control is outside the FORM tag:
<form method="POST" name="testForm"
action="enter URL address here">
Name: <input type="text"
name="name" size="20">
<BR>
Email: <input type = "text"
name="email" size="35">
<BR>
</form>
<input type="submit" value="Submit"
name="submit">
<input type="reset" value="Reset"
name="reset">
|
Explorer will display the Submit and Reset buttons, but won't process the commands. When you press the Submit button to send the information, you'll wait and wait and wait - and nothing will happen. Netscape is more unforgiving and won't display the buttons at all. Both Netscape and Explorer display the information differently, but neither actually submits the information.
Here's the page in Explorer:
And in Netscape:
Since you can't immediately see the error in an editor or in Explorer, always make sure to rigorously test your forms in all browsers before you post your Web site. You could have some extremely unhappy visitors if they input information into a long form and then can't submit it. They're unlikely to try a second time and you could lose both credibility (and sales!) from a simple error.
HTML 4.0 Standards Aren't Standard - Yet
HTML 4.0 guidelines state that all HTML controls should work whether they are inside or outside a FORM tag, but neither Netscape nor Explorer fully supports this suggested standard yet. HTML control elements define the type and function of the input controls of a form. Common HTML control elements are: <SELECT>, <BUTTON>, and <INPUT>.
There are specific situations where you might want HTML controls outside a form tag. While it doesn't sound like good coding practice, the technique can be useful if you're trying to create interactive documents. Use the controls with scripting code that allows the user to execute commands on the page.
If you're trying to create this type of interactive application, bypass the Netscape problem by placing the elements inside a <FORM> tag and set the ACTION attribute to ACTION=" ". Then, both Netscape and Explorer can display and execute them.
Otherwise, if you want your visitors to be able to submit information to you, be sure your INPUT tag is properly placed with the other controls inside your FORM tag. NetMechanic's HTML Toolbox makes this task easy: it analyzes and identifies many coding errors that can affect your Web page's display and functionality.
When visitors make the effort to communicate with you, be absolutely sure you that you always get the message!
|