• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Javascript Form Expansion

I am looking to create a form that expands when a checkbox is clicked. The form I am making is for a conference center. There is a checkbox that states "Full Service." If the checkbox is checked I want the form to expand to include other options. For example if checked I want the form to expand and have checkboxes for "Projector," "Drinks," "Microphone," etc. What is the best way to do this? Wouldn't Javascript be the best way and if so how would I do this? Would a lightbox be the best idea? Could this be done dynamically loading the expanded form using php?
  • 2
1 Solution
are you trying to create a expand/collapse functionality using check box. if yes you could try placing the items inside a div, where everytime you trigger a expand/collapse. the div are shown or hide.

NEComputerAuthor Commented:
I am not sure if that is exactly what I am creating because I need to collect the data from the form on whether or not the event is "full service." I have created an expand/collapse before using div and css show and hide. This however has been glitchy and don't know how best to create it. Any guidance?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<script language="JavaScript" type="text/javascript">
function toggle(eid){
	eid = document.getElementById(eid);
	eid.style.display=eid.style.display=="" ? "none" : "";
<input type="checkbox" name="service" value="Full Service" onclick="toggle('FullService')"/>Full Service
<div id="FullService" style="display:none;">
	<div><input type="checkbox" name="service" value="Projector"/>Projector</div>
	<div><input type="checkbox" name="service" value="Drinks"/>Drinks</div>
	<div><input type="checkbox" name="service" value="Microphone"/>Microphone</div>

Open in new window

NEComputerAuthor Commented:
Thanks for the solution. It works great! I added some sytle to the form and things still work. If I understand it properly, whatever ID I give the control I give to the objects I want the change to apply to. Again I appreciate the support. Thank You.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now