Web Analytics Made Easy -
StatCounter Removing form elements (submit inputs) - CodingForum

Announcement

Collapse
No announcement yet.

Removing form elements (submit inputs)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing form elements (submit inputs)

    I'm using the following code to remove submit inputs after they have been clicked to stop double form processing.

    Code:
    gg=false;
    function di(r)
    {
     for (i=0;i < r.elements.length;i++)
     { if (r.elements[i].type=='submit')
        r.elements[i].style.visibility='hidden';
     }
     if(gg==false)
     {
      gg=true;
      return true;
     }
     else
      return false;
    }
    
    function grabit()
    {
     for(i=0;i < document.forms.length;i++)
      document.forms[i].onsubmit = function() {return di(this);};
    }
    I don't really know very much about js, but i think that i am supposed to name the forms which i wish it to work on, as "r".

    The problem is, what if i want every submit input on a page to dissappear, but they are in different forms? I have tried naming them all as "r" but only the submit inputs inside the form that i click an inout from, will dissappear.

    Thanks in advance for any help, and please correct me if i have gone totally wrong with my understanding of the above code.

  • #2
    anyone?

    Comment


    • #3
      rough e.g.
      Code:
      function prvntDblSbmt(obj) {
      	
      	var frmInputs = obj.getElementsByTagName('input');
      	for (var i = 0, tInput; tInput = frmInputs[i]; i++) {
      		if (tInput.type == 'submit') { tInput.disabled = true; }
      	}
      	
      }
      Code:
      <form action="./" method="post" onsubmit="prvntDblSbmt(this)">
      	…
      	<input type="submit" value="Submit" />
      	…
      </form>
      Last edited by Bill Posters; Sep 27, 2006, 08:45 AM.
      Why you should validate your code before asking for help...

      Comment

      Working...
      X