Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Abd
    Abd is offline
    New Coder
    Join Date
    Aug 2002
    Location
    Lagos, Nigeria
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Hide Textfield in IE and Netscape

    Hi All,

    I use this code to hide a textfield, it works in IE but it doesn't work when I load the page in Netscape. Any Help?

    <SCRIPT LANGUAGE="JavaScript">

    //To Hide Textbox

    document.getElementById("sr").style.display = 'none'

    </SCRIPT>

    Abd
    Abdul

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Netscape

    It works in NS 6 or higher... If you try it in an older version of NS, you must use first a browser detector and then, probably, for NS 4.x you may try the syntax

    document.layers[id]

    instead of

    document GetElementById(id).style
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It isn't going to work in Netscape 4.x at all. In NS4 you can only show/hide entire layers, putting the input field into a layer would require adding another set of <form></form> for the field and then more code to pull the result from that field to inset it into a hidden field in the main form. That's a lot of work just to support an obsolete, bug infested browser used by a very small percentage of the web. The best approach for handling NS4 is to treat it just like a version 3 browser and turn off all the "dynamic" sttuff.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    It is not so hard to hide/show an element using "id", even in NS 4.x. It is just another syntax. True, you have to use <layer> and <ilayer> tags, as NS 4.x cannot recognize <div> or <span> to be sure that the "id" atribute is accepted, but, after you run a browser detector script, and an objectSetup function, the rest is simple, something like:

    function layerSetup(id,visibility) {
    if (is.ie5||is.ie55||is.ie6||is.ns6){
    this.obj = document.getElementById(id).style;
    this.obj.visibility = visibility;
    return this.obj;
    } else if(is.ie4) {
    this.obj = document.all[id].style;
    this.obj.visibility = visibility;
    return this.obj;
    } else if(is.ns4) {
    this.obj = document.layers[id];
    this.obj.visibility = visibility;
    return this.obj;
    }
    }

    ...now you can make an element visible/hidden for IE4 and NS4 also... If you want to, you may include other style, arguments, such as position, and make thus the object move...

    Need anyone the full script?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •