Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Changing input type in IE?

Reply
Thread Tools

Changing input type in IE?

 
 
cjl
Guest
Posts: n/a
 
      10-18-2005
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

 
Reply With Quote
 
 
 
 
Gomolyako Eduard
Guest
Posts: n/a
 
      10-18-2005
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


 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-18-2005

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/
 
Reply With Quote
 
web.dev
Guest
Posts: n/a
 
      10-18-2005

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.

 
Reply With Quote
 
cjl
Guest
Posts: n/a
 
      10-18-2005
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

 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      10-18-2005
cjl <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to restrict user from input in <input type="file"> Tarkeshwar Javascript 2 04-17-2006 11:44 AM
changing input.type error with IE Michael Winter Javascript 2 10-14-2004 05:12 PM
changing input type file Gladriel ASP .Net Building Controls 1 05-17-2004 05:00 PM
Coloring input type=input browse button; uploading multiple files Ron Brennan Javascript 5 05-14-2004 08:13 PM
Changing Input Type, length and value Boyd Reilly Javascript 4 01-13-2004 12:49 PM



Advertisments