SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Aug 18, 2002, 21:22 #1
- Join Date
- Nov 2001
- Location
- Brisbane, Australia
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
changing visibility depending on dropdown box selection
Hi Everyone,
I want a text box which is only visible if the preceding drop down box has a certain option selected.
Does anyone know how to do this or where I might be able to find the appropriate code?
Thanks,
Dan
-
Aug 18, 2002, 23:03 #2
- Join Date
- Nov 2001
- Location
- Brisbane, Australia
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok this is what I've done so far, but it still doesn't work.
I've placed a <div> with the id "audit" around the text box and set the style to visibility:hidden. Then on the drop down menu called "type", I've placed an onchange which performs the function called visible_no.
The code for visble_no is:
<i>function visible_no(){
if (document.type.value = "audit issue") {
div.audit.style = "visibility:visible";
}
else{
div.audit.style = "visibility:hidden";
}</i>
If anyone can help, I'd greatly appreciate it.
Thanks.
-
Aug 18, 2002, 23:06 #3
- Join Date
- Nov 2001
- Location
- Brisbane, Australia
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
forget the <i>'s I thought it would display my code in italics
-
Aug 19, 2002, 03:05 #4Code:
function visible_no(what){ if (what.value = "audit issue") { div.audit.style.visibility = "visible"; } else{ div.audit.style.visibility = "hidden"; }
Code:<form name="form1" action="" enctype=""> <select name="type" onchange="javascript:visible_no(this);"> <!--...//--> </select> </form>
I beg your pardon for my bad English
-
Aug 19, 2002, 20:01 #5
- Join Date
- Nov 2001
- Location
- Brisbane, Australia
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yep, I had an onchange in the select tag.
It's now telling me that "div is not defined" (referring toPHP Code:div.audit.style.visibility = "visible";
This is how I've got the <div> in the body code.
PHP Code:<div id="audit" style="visibility:hidden">Audit No. : <input type="text" name="textfield"></div>
-
Aug 19, 2002, 21:35 #6
- Join Date
- Nov 2001
- Location
- Brisbane, Australia
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
By the way, that's Netscape giving me that error. IE works fine.
I don't think it's necessary for it to work in Netscape because the only people that will need to fill in that visible/invisible field are people who work within the company and IE is the only browser in use.
So thanks for your help, Toxical.
-
Aug 20, 2002, 02:28 #7
Oh yes, havn't thought 'bout that div so far
try
PHP Code:document.audit.style.visibility = "visible";
//or
document.all.audit.style.visibility = "visible";
//or
document.getElementById("audit").style.visibility = "visible";
I beg your pardon for my bad English
-
Aug 20, 2002, 16:41 #8
- Join Date
- Nov 2001
- Location
- Brisbane, Australia
- Posts
- 108
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Toxical
PHP Code:document.getElementById("audit").style.visibility = "visible";
This was the one that worked. Thanks again for your help.
Dan
Bookmarks