changing input.type error with IE

Discussion in 'Javascript' started by Michael Winter, Oct 14, 2004.

  1. On Thu, 14 Oct 2004 17:49:53 +0100, vastaso <> wrote:

    > Ciao, I have an hidden field and I want make it visible, setting its
    > "type"


    [snip]

    > it works fine in Mozilla but fails in Internet Explorer 6.


    Microsoft have taken the liberty of making the type property read-only[1].
    It would be a better idea to hide the element when the document loads
    using the style object, then making it visible later.

    When the document loads:

    var elemRef = ...;

    if(elemRef && elemRef.style) {
    elemRef.style.visibility = 'hidden'; // or .display = 'none';
    }


    When you want to show the element:

    var elemRef = ...;

    if(elemRef && elemRef.style) {
    elemRef.style.visibility = ''; // or .display = '';
    }

    Hope that helps,
    Mike


    [1] Well, it can be written to once, but only it the element in question
    has just been created with a document.createElement call.

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Oct 14, 2004
    #1
    1. Advertising

  2. Michael Winter

    vastaso Guest

    Ciao, I have an hidden field and I want make it visible, setting its "type"
    to "text" from a popup window.
    I'm using this code:
    window.opener.document.forms['formInsegnamenti'].elements['giorni_1'].type
    ='text';

    it works fine in Mozilla but fails in Internet Explorer 6.

    Any ideas?
    Thanks
     
    vastaso, Oct 14, 2004
    #2
    1. Advertising

  3. Michael Winter

    vastaso Guest

    "Michael Winter" <> ha scritto nel messaggio
    news:eek:psfvao4fxx13kvk@atlantis...
    > On Thu, 14 Oct 2004 17:49:53 +0100, vastaso <> wrote:
    >
    > When the document loads:
    >
    > var elemRef = ...;
    >
    > if(elemRef && elemRef.style) {
    > elemRef.style.visibility = 'hidden'; // or .display = 'none';
    > }
    >
    >
    > When you want to show the element:
    >
    > var elemRef = ...;
    >
    > if(elemRef && elemRef.style) {
    > elemRef.style.visibility = ''; // or .display = '';
    > }
    >
    > Hope that helps,
    > Mike


    Oh YES! It helps!!
    Thank you very much
     
    vastaso, Oct 14, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gladriel

    changing input type file

    Gladriel, May 17, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    185
    Teemu Keiski
    May 17, 2004
  2. Boyd Reilly

    Changing Input Type, length and value

    Boyd Reilly, Jan 11, 2004, in forum: Javascript
    Replies:
    4
    Views:
    152
    Jim Ley
    Jan 13, 2004
  3. Ron Brennan
    Replies:
    5
    Views:
    328
    Dr John Stockton
    May 14, 2004
  4. cjl

    Changing input type in IE?

    cjl, Oct 18, 2005, in forum: Javascript
    Replies:
    5
    Views:
    151
    Christopher Benson-Manica
    Oct 18, 2005
  5. Tarkeshwar
    Replies:
    2
    Views:
    204
Loading...

Share This Page