|
-
Nov 6th, 2002, 04:41 AM
#1
Thread Starter
Addicted Member
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.
-
Nov 6th, 2002, 06:06 AM
#2
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> </P>
</BODY>
</HTML>
-
Nov 6th, 2002, 08:00 AM
#3
Thread Starter
Addicted Member
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.
-
Nov 6th, 2002, 08:52 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|