cr************@gmail.com wrote:
In firefox works fine,,,
Someone can explain to me?
function hiddenono(objeto)
{
if (objeto.type == 'hidden')
{objeto.type='text';}
else
{objeto.type='hidden';}
}
IE doesn't let you change the type of an input dynamically. If your
intention is to simply hide or show the input, then modify its CSS
visibility or display attribute.
In DOM 1, an input's type attribute was readonly - that was changed in
DOM 2.
DOM 1 HTMLInputElement:
<URL:
http://www.w3.org/TR/REC-DOM-Level-1...tml#ID-6043025 >
DOM 2 HTMLInputElement:
<URL:
http://www.w3.org/TR/DOM-Level-2-HTM...tml#ID-6043025 >
If you really need to change the input's type, a rather ugly hack is to
modify the element's outerHTML if you can (lightly tested in IE and
Firefox, wrapped for posting):
function hiddenono(objeto)
{
if (objeto.type == 'hidden') {
formElChangeType(objeto, 'text');
} else {
formElChangeType(objeto, 'hidden');
}
}
function formElChangeType(el, newType){
var reA = new RegExp(
'type\\s*=\\s*[\\"\\\']*\\w+[\\s\\"\\\']+','i' );
var reB = new RegExp(
'type\\s*=\\s*[\\"\\\']?\\w+[\\s\\"\\\']?','i' );
var s = el.outerHTML;
if (s) {
if (reA.test(s)){
el.outerHTML = s.replace(reB, 'type='+newType+' ');
} else {
el.outerHTML = s.replace(/<input/i, '<input '
+ 'type='+newType+' ');
}
} else {
el.type = newType;
}
}
--
Rob