Changing input type in IE?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cjl

    Changing input type in IE?

    Hey all:

    This code:

    if (stealth)
    {
    document.search me.query.type = 'password';
    }
    else
    {
    document.search me.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

    #2
    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 писал(а):
    [color=blue]
    > Hey all:
    >
    > This code:
    >
    > if (stealth)
    > {
    > document.search me.query.type = 'password';
    > }
    > else
    > {
    > document.search me.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[/color]

    Comment

    • Martin Honnen

      #3
      Re: Changing input type in IE?


      cjl wrote:
      [color=blue]
      > Are there any work around for changing input type dynamically in IE?[/color]

      You can create a new input with
      var input = document.create Element('input' )
      and set the type on that, then swap the elements with e.g.
      oldInput.parent Node.replaceChi ld(input, oldInput);


      --

      Martin Honnen

      Comment

      • web.dev

        #4
        Re: Changing input type in IE?


        Martin Honnen wrote:[color=blue]
        > cjl wrote:
        >[color=green]
        > > Are there any work around for changing input type dynamically in IE?[/color]
        >
        > You can create a new input with
        > var input = document.create Element('input' )
        > and set the type on that, then swap the elements with e.g.
        > oldInput.parent Node.replaceChi ld(input, oldInput);[/color]

        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.

        Comment

        • cjl

          #5
          Re: Changing input type in IE?

          Hey all:

          Thank you to all who replied.
          [color=blue]
          > 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.[/color]

          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

          Comment

          • Christopher Benson-Manica

            #6
            Re: Changing input type in IE?

            cjl <cjlesh@gmail.c om> wrote:
            [color=blue]
            > All of this makes me not want to support IE, which up until this point
            > I have been making compromises to do.[/color]
            [color=blue]
            > This is getting complicated.[/color]

            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)cybers pace.org | don't, I need to know. Flames welcome.

            Comment

            Working...