PDA

View Full Version : Show Hidden javascript breaking forms



OverlordQ
Feb 14th, 2004, 02:41 AM
here it is edited for readability:


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.

beetle
Feb 14th, 2004, 05:12 AM
That's because it removes them, I think


e.parentNode.removeChild(e);

OverlordQ
Feb 14th, 2004, 06:38 AM
Yea but right after that is:



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 . . .