Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryManaging Website Forms

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Form Development Time Saver

Sometimes, large forms can be a challenge to develop – the order of the field names, misspelled field names, and keeping track of them all.

The JavaScript in this article lists all field names for you, right on the page with the form.

The JavaScript-generated list gives you a quick visual of what the form contains.

The form fields are printed in the order they appear. The list allows you to compare what the form has with what you thought it had.

Further, field names can be copied from the generated list for pasting into your JavaScript or other scripts, like PHP and Perl CGI.

Here's how to set it up.

The form tag needs an id value. Example:

<form id="my-form" method="post" action="/script.php">

The form id value is colored blue for easy recognition.

And here's the JavaScript. Customization and implementation notes follow.

<script type="text/javascript">
// Specify the id value of the form tag.

var FormIDvalue = "my-form";

// End of customization.
var form = document.getElementById(FormIDvalue);
for( var i=0; i<form.length; i++ )
{
   document.write(form[i].name + "<br>");
}
</script>

The JavaScript has one place to customize. Specify the id value of the form tag where indicated. The example id value is colored blue for easy recognition.

To implement, paste the JavaScript somewhere below the form. That's it.

Reload the page and you'll have your list of form field names.

When done with development, remove the JavaScript.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC