?
Solved

Hiding a form

Posted on 2003-03-11
7
Medium Priority
?
182 Views
Last Modified: 2010-07-27
I have a form of for example 30 text boxes, about half way is a Combo box with YES or NO, what i want is if it says YES in this box i want the rest of the form to be visible,

I DO NOT WANT TO SUBMIT THE FORM, I remember doing something similar with <DIV> tags, but cannot for the life of me remember how.

I want the code to be the shortest possible,

If you can hide a comple table that would be great.

Bolox
0
Comment
Question by:bolox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:neongrau
ID: 8110306
hi!

using a div is correct try this:

<form>

defaultform elements go here

<input type=checkbox name=optionals value=1 onClick="if (this.checked) { document.getElementById('hidden').style.display='block'; } else { document.getElementById('hidden').style.display='none'; }">


<div id=hidden style="display:none">
optionals go here
</div>

</form>
0
 
LVL 1

Author Comment

by:bolox
ID: 8111271
what about if i where to use a drop down select box?

Thankyou for the checkbox code, also very helpful.
0
 
LVL 2

Expert Comment

by:neongrau
ID: 8111338
hi again!

then you could use this instead of the checkbox:

<select name=optionals onChange="if (this.value!='no') { document.getElementById('hidden').style.display='block'; } else { document.getElementById('hidden').style.display='none'; }">
<option value=yes>yes</option>
<option value=no>no</option>
<option value=maybe>maybe</option>
</select>

regards
~neongrau
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Expert Comment

by:neongrau
ID: 8111366
sorry forgot a word..

<option value=no selected>no</option>
0
 
LVL 1

Author Comment

by:bolox
ID: 8111452
I am pulling out the Initial starting YES / NO default option, so if it where YES it would not show by default and visa-versa, What should i put in the BODY ONLOAD to check this?

Regards

Bolox   AKA Gavin
0
 
LVL 2

Accepted Solution

by:
neongrau earned 200 total points
ID: 8111731
<body onLoad="optionals(document.getElementById('optionals'))">

<script language=JavaScript>
function optionals(that) {
  if (that.value !='no' ) {
    document.getElementById('hidden').style.display='block';
  } else {
    document.getElementById('hidden').style.display='none';
  }
}
</script>

<form>

defaultform elements go here

<select id=optionals name=optionals onChange="optionals(that)">
<option value=yes>yes</option>
<option value=no selected>no</option>
<option value=maybe>maybe</option>
</select>

<div id=hidden style="display:none">
optionals go here
</div>

</form>

</body>
0
 
LVL 1

Author Comment

by:bolox
ID: 8112102
You are a credit to EE,

Thankyou very much for the help.

More than likely i will be chatting with you again

Regards

B
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question