Web Analytics Made Easy -
StatCounter Show Hidden javascript breaking forms - CodingForum

Announcement

Collapse
No announcement yet.

Show Hidden javascript breaking forms

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

  • Show Hidden javascript breaking forms

    here it is edited for readability:
    Code:
    javascript:(
    function(){
    	var i,f,j,e,div,label,ne; 
    	for(i=0;f=document.forms[i];++i)
    		for(j=0;e=f[j];++j)
    			if(e.type==%22hidden%22){ 
    				D=document; 
    				function C(t){
    					return D.createElement(t);
    				} 
    				function A(a,b){
    					a.appendChild(b);
    				} 
    				div=C(%22div%22); 
    				label=C(%22label%22); 
    				A(div, label); 
    				A(label, D.createTextNode(e.name + %22: %22)); 
    				e.parentNode.insertBefore(div, e); 
    				e.parentNode.removeChild(e); 
    				ne=C(%22input%22);
    				ne.type=%22text%22; 
    				ne.value=e.value; A(label, ne); 
    				label.style.MozOpacity=%22.6%22; 
    				--j;
    			}
    }
    )
    ()
    That's what I found somewhere, the problem is, all the hidden fields, after running this java script, dont get submitted with the form anymore. Any help would be most appreciated.

  • #2
    That's because it removes them, I think
    Code:
    e.parentNode.removeChild(e);
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

    Comment


    • #3
      Yea but right after that is:

      Code:
      				ne=C(%22input%22);
      				ne.type=%22text%22; 
      				ne.value=e.value; A(label, ne);
      the C function creates a new 'input' element changes the type to text and then set's the value of the old element to the new element . . .

      Comment

      Working...
      X