Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Hiding a form

Posted on 2003-03-11
7
Medium Priority
?
183 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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

564 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