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
https://forums.phpfreaks.com/topic/85245-please-help-me-with-my-code/
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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.