We help IT Professionals succeed at work.
Get Started

I am trying to toggle a fieldset in javascript however I am having trouble here is a snippet of my code

1030071002
1030071002 asked
on
293 Views
Last Modified: 2012-04-24
I am trying to toggle a fieldset in javascript however I am having trouble here is a snippet of my code

<fieldset class="shipBillSame">
	<label> IF THE CUSTOMER INFO IS THE SAME AS THE BILL TO CLICK THE BOX :
	<input type="checkbox" name="option" id="option1" value=""  onClick="checkAddress();"/>
   </label>
</fieldset>

<div id="priv_info">
    <fieldset class="billto">
    
    <legend>Bill To</legend>
        <label>Name : </label><input name="billto_name"  maxlength="49" id="billto_name" type="text" ><span class="req">*</span>
        <label>Address : </label>
        <input name="billto_address"  maxlength="49"  id="billto_address" type="text"><span class="req">*</span>
        <label>City/State/Zip : </label>
        <input name="billto_city"  maxlength="30" id="billto_city" type="text" class="shortInput1"  />
        <input name="billto_state"  maxlength="2" id="billto_state" type="text" class="shortInput2"  /> 
        <input name="billto_zip" maxlength="8"  type="text" id="billto_zip" class="shortInput3"  /><span class="req">*</span> 
        <label>Contact : </label>
        <input name="billto_contact" maxlength="30"  id="billto_contact" type="text"><span class="req">*</span>
        <label>Email : </label>
        <input name="billto_email" maxlength="49"  id="billto_email" type="text">
        <label>Phone/Fax : </label>
        <input name="billto_tel" maxlength="20"  id="billto_phone" type="tel"> 
        <input name="billto_fax" maxlength="20"  id="billto_fax" type="tel"><span class="req">*</span></legend>
    </fieldset>
</div>

<fieldset>
  <legend>Secret Question and Answer</legend>
  <label>Secret Question : </label><input name="secret_question"  maxlength="49" id="Secret_Question" type="text" ><span class="req">*</span>
  <label>Answer : </label><input name="secret_answer"  maxlength="49" id="Answer" type="text" ><span class="req">*</span>
</fieldset>

<div class="buttons"><input type="submit" name="Submit" id="Submit" value="Submit" tabindex="0">
    <input type="reset" name="New" id="reset" value="reset" tabindex="1">
    <input type="button" name="Exit" id="Exit" value="Exit" onClick="self.close()" tabindex="2">
</div>
</form>  

<script type="text/javascript">
function prepareForm(){
	if(!document.GetElementByid){
		return false
	}
	var form = document.GetElementById('registration');
	togglebillto = form.elements["option"];
	togglebillto.onclick = togglePrivInfo;
	togglebillto.onclick();
    }
	function togglePrivInfo(){
		toggle('priv_info');
	}
	function toggle(id){
	 var element = document.getElementByid(id);
	 var display = (element.style.display === 'none') ? '' : 'none';
	 element.style.display = display;	
	}
	prepareForm();
</script>

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 5 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE