Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Changing input type in IE? (http://www.velocityreviews.com/forums/t920823-changing-input-type-in-ie.html)

cjl 10-18-2005 03:22 PM

Changing input type in IE?
 
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


Gomolyako Eduard 10-18-2005 04:00 PM

Re: Changing input type in IE?
 
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



Martin Honnen 10-18-2005 04:06 PM

Re: Changing input type in IE?
 

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/

web.dev 10-18-2005 05:38 PM

Re: Changing input type in IE?
 

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.


cjl 10-18-2005 06:53 PM

Re: Changing input type in IE?
 
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


Christopher Benson-Manica 10-18-2005 08:41 PM

Re: Changing input type in IE?
 
cjl <cjlesh@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.


All times are GMT. The time now is 08:35 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.