Results 1 to 4 of 4

Thread: Making form elements visible or invisible

  1. #1

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Making form elements visible or invisible

    Hi,

    Thanks for reading this.

    I want to hide and show form elements(text and radio alternatively according to condition). All the elements shud be in a single form, so that I can access the values using JavaScript and it should work in IE and Netscape.

    Thanks,
    Pres.

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Here's a quick example not too sure about browser compatibility
    Code:
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    <script>
    function test(){
    	var obj = document.frm.txt.style;
    	obj.visibility = (obj.visibility == 'hidden')?'visible':'hidden';
    	return true;
    }
    </script>
    </HEAD>
    <BODY>
    <form name="frm">
    	<input type="text" name="txt" style="visibility:visible">
    	<input type="button" name="btn" value="click" onclick="test();">
    </form>
    <P>&nbsp;</P>
    
    </BODY>
    </HTML>

  3. #3

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Not working in Netscape 4.79

    Hi,

    Thanks for your reply. I tried your code in IE. It works fine. But in Netscape 4.79 it says
    "obj has no properties"
    and it isn't working. Is there any way I can make this work in Netscape 4.79


    Thanks,
    Pres.

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    I had only tested it in IE and Opera cos I don't have Netscape here.
    It would appear that Netscape 4 exposes styles through the
    tags, classes and ids properties and does not
    provide access to inline styles (where style is set in the tag)

    So I assume this means you have to set up a style, set
    the input class equal to that style and have code like:
    document.formname.tags.INPUT.visible

    but this is all guess work,sorry

Posting Permissions

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



Click Here to Expand Forum to Full Width