Jump to content

Please help me with my code


temujinleal

Recommended Posts

good day!! my problem is, i wanted to automatically toggle back my last checked application if two checkboxes are checked.. here's the code..

 

<script language="javascript">
	  function toggleDiv(divid)
	  {
		if(document.getElementById(divid).style.display == 'none')
		{
		  document.getElementById(divid).style.display = 'block';
		}
		else
		{
		  document.getElementById(divid).style.display = 'none';
		}
	  }
	  
	  function keepCount() 
	  {
            var NewCount = 0

	    if (document.check_box.facility1.checked)
		{
	      NewCount = NewCount + 1
		}

	    if (document.check_box.facility2.checked)
	    {
		  NewCount = NewCount + 1
		}

	    if (NewCount == 2)
	    {
	      alert('Pick Just One Please')
	      document.check; return false;
	    }
	  } 
	  
	  
	</script>

   <form name="check_box">	
   <input name="facility1" type="checkbox" value="Rooms" onclick="toggleDiv('rooms_r'); return keepCount();"   />
   <input name="facility2" type="checkbox" value="Conference Rooms" onclick="toggleDiv('conf_rooms'); return keepCount();" />
   
   <div id="rooms_r" style="display:none">sample</div>
   <div id="conf_rooms" style="display:none">another sample</div>
   
   </form>

 

 

 

thanks in advance!! sorry for my grammar if you can't understand.. the code that i've posted is complete.. i just want some idea how to change it... thanks!

Link to comment
Share on other sites

<script language="javascript">
	  function toggleDiv(divid)
	  {
		if(document.getElementById(divid).style.display == 'none')
		{
		  document.getElementById(divid).style.display = 'block';
		}
		else
		{
		  document.getElementById(divid).style.display = 'none';
		}
	  }
	  
	  function keepCount(divid) 
	  {
            var NewCount = 0

	    if (document.check_box.facility1.checked)
		{
	      NewCount = NewCount + 1
		}

	    if (document.check_box.facility2.checked)
	    {
		  NewCount = NewCount + 1
		}

	    if (NewCount == 2)
	    {		     
	      alert('Pick Just One Please');
                      document.getElementById(divid).style.display='none';
	      document.check; return false; 
	    }
	  } 
	  
	  
	</script>

   <form name="check_box">	
   <input name="facility1" type="checkbox" value="Rooms" onclick="toggleDiv('rooms_r'); return keepCount('rooms_r');"   />
   <input name="facility2" type="checkbox" value="Conference Rooms" onclick="toggleDiv('conf_rooms'); return keepCount('conf_rooms');" />
   
   <div id="rooms_r" style="display:none">sample</div>
   <div id="conf_rooms" style="display:none">another sample</div>
   
   </form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.