Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMasterBlog > HTML

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 Debug Helper

If you have made numerous large forms, you know how hard it can be to find a mistake that slipped through.

Two name attributes with the same value, for example. A hyphen in a name value that had been meant as an id value. A set of radio buttons with different names rather than all the same. Maybe there's an extra form tag somewhere on the page.

Those are a sampling of possibile bugs.

It requires a lot of detailed reading of code to find some of those elusive mistakes, especially with large forms.

If you've used a data dump to submit the form, and still were unable to find the problem, consider using the Form Debug Helper for a view of the elements.

The helper prints a list containing each form and its fields. The field's attributes name, id, type, and value, and its checked state, are listed when they are available.

That's all it does, list the forms and fields and field attributes found on the web page. It does not attempt to find bugs. It's purpose is to present an uncluttered view of what your form(s) are constructed with.

Form Debug Helper's output is intended to help you see where bugs or mistakes might be.

Here is the source code for Form Debug Helper.

<pre id="poss-js-poss_form-data" style="border:6px dashed #ccc; padding:9px; display:table;"></pre>
<script type="text/javascript">
let poss_OutputDiv = document.getElementById("poss-js-poss_form-data");
let poss_forms = document.getElementsByTagName("poss_form");
for( var poss_form=0; poss_form<poss_forms.length; poss_form++ )
{
   if(poss_form) { poss_OutputDiv.innerHTML += "\r\n\r\n\r\n"; }
   poss_OutputDiv.innerHTML += "<b style='font-size:125%;'>poss_form # " + (poss_form+1) + "</b>";
   poss_OutputDiv.innerHTML += "\r\nposs_form ID: " + poss_forms[poss_form].id ;
   poss_OutputDiv.innerHTML += "\r\nposs_form action: " + poss_forms[poss_form].action;
   for( var i=0; i<poss_forms[poss_form].length; i++ )
   {
      var type = poss_forms[poss_form][i].type;
      var ta = new Array();
      ta.push("ID: "+poss_forms[poss_form][i].id);
      ta.push("Type: "+type);
      ta.push("Name: "+poss_forms[poss_form][i].name);
      if( type=="select-multiple" ) { ta.push("First selected value: "+poss_forms[poss_form][i].value); }
      else { ta.push("Value: "+poss_forms[poss_form][i].value); }
      if(type=="checkbox" || type=="radio") { ta.push("Checked: "+(poss_forms[poss_form][i].checked?"Yes":"No")); }
      poss_OutputDiv.innerHTML += "\r\n\r\n" + ta.join("\r\n");
   }
}
</script>

Temporarily paste the above code into the end of the page, or at least somewhere below the last form. No customization required. Before going live with the page, remove the temporary code.

Form Debug Helper prints the data uncluttered. It is possible that you may see the glitch you are looking for with your first scan through the output.

The only code you need is the above source code.

To illustrate how it works, here are 2 forms and the output of the Form Debug Helper.

Form #1

Your name:

Your birth date:

Check if you like blue. Blue

Choose from red or green. Red Green

File to upload.

Select a color.

Select a color.

Tap to submit the form.

Tap to play with the button.

Form #2

Your country:

The above are the forms. The below is the output of Form Debug Helper for the above forms.



The Form Debug Helper tool lists every form field on a web page to help you debug the things. Use it when you need it.

To reiterate, temporarily paste the code into the end of a web page. When done debugging, remove the temporary code and you're good to go.

(This content first appeared in Possibilities newsletter.)

Will Bontrager

Was this blog post 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 Blog 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.

Recent Articles in the Library

Keeping Image Location Secret

The URL of an image embedded in a web page may be kept secret.

Easier Reading of JSON Data

For easier reading of JSON data, convert the JSON into an array.

Fixed Position Image

Position an image within a browser window that won't move even with page scroll.

Visually Centering Images

Sometimes an image that is technically centered doesn't look quite centered when viewed.

Cookie Directory Protection

Protecting subdirectories with a cookie can be an especially good method when access needs to be allowed from various internet connections.

Check SSL Certificate

An easy-to-use SSL checker to see when your secure certificate expires.

Strong Form Protection From Bots

A web page form that is invisible to spam bots.

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