Software, your way.
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

Tap to Select

Find out how to make a link or button to select the content in a div or other HTML element.

Capitalizing the First Letter of Words

Here, find both PHP code and JavaScript code to capitalize the first letter of a word.

Fixed-position Table Header

During a vertical scroll, the table header scrolls out of view -- unless the header is fixed in position.

Simple Floating Menu

When not needed, the menu on the left side of a web page retracts to be out of the way. Tap it and it expands.

CSS Drop Shadows for Images

Images can be given drop shadows using pure CSS.

Ajax File Upload

Learn how to upload a file as soon as a file upload form field is given a file to upload.

Another Form Spam Prevention Technique

This technique should stop much or most of the form spam you are experiencing, perhaps even all of it.

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