By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Changing input type in IE?

P: n/a
cjl
Hey all:

This code:

if (stealth)
{
document.searchme.query.type = 'password';
}
else
{
document.searchme.query.type = 'text';
}

works in FF but not in IE 6. It fails with "Error: Could not get the
type property. This command is not supported."

A previous post mentioned that in IE type is 'read only'.

Are there any work around for changing input type dynamically in IE?

Thanks in advance,
-CJL

Oct 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
You can dynamically insert new "input" element with correct type before
"query", after that remove "query" element and rename added "input"
element to "query".

Or you can define to "input" elements: one with text type, other with
password type and dynamically disable incorrect element. Disabled
inputs don't posts to server.

Best, Ed.

cjl писал(а):
Hey all:

This code:

if (stealth)
{
document.searchme.query.type = 'password';
}
else
{
document.searchme.query.type = 'text';
}

works in FF but not in IE 6. It fails with "Error: Could not get the
type property. This command is not supported."

A previous post mentioned that in IE type is 'read only'.

Are there any work around for changing input type dynamically in IE?

Thanks in advance,
-CJL


Oct 18 '05 #2

P: n/a

cjl wrote:
Are there any work around for changing input type dynamically in IE?


You can create a new input with
var input = document.createElement('input')
and set the type on that, then swap the elements with e.g.
oldInput.parentNode.replaceChild(input, oldInput);
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 18 '05 #3

P: n/a

Martin Honnen wrote:
cjl wrote:
Are there any work around for changing input type dynamically in IE?


You can create a new input with
var input = document.createElement('input')
and set the type on that, then swap the elements with e.g.
oldInput.parentNode.replaceChild(input, oldInput);


cjl,

In addition to what Martin wrote, after you create the "input" element,
you can only set the type once (in IE). If you try to set the type
again, then you'll get the error message again.

Oct 18 '05 #4

P: n/a
cjl
Hey all:

Thank you to all who replied.
Martin Honnen wrote:
In addition to what Martin wrote, after you create the "input" element,
you can only set the type once (in IE). If you try to set the type
again, then you'll get the error message again.


All of this makes me not want to support IE, which up until this point
I have been making compromises to do.

My users need to be able to swap between stealth mode and normal mode,
so I guess I could have two input text boxes, and show or hide them
dynamically based on what mode they choose, but then I would have to
copy the text input from one to another to make it seamless.

This is getting complicated.

Thanks again,
CJL

Oct 18 '05 #5

P: n/a
cjl <cj****@gmail.com> wrote:
All of this makes me not want to support IE, which up until this point
I have been making compromises to do. This is getting complicated.


Cross-browser scripting is inherently complicated. Not supporting IE
doesn't strike me as a viable option.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Oct 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.