View Single Post
Old 09-05-2012, 01:39 PM   PM User | #6
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 957
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by ajaynayak7 View Post
Hi,
That means It should allow very next and previous checkboxes and other should be readonly.
The question still isn't clear, but is this anywhere close?
Code:
<body>
<form id='myForm'>
<input name = "theDay" type = "checkbox" value = "Sunday"> Sunday <br>
<input name = "theDay" type = "checkbox" value = "Monday"> Monday <br>
<input name = "theDay" type = "checkbox" value = "Tuesday"> Tuesday <br>
<input name = "theDay" type = "checkbox" value = "Wednesday"> Wednesday <br>
<input name = "theDay" type = "checkbox" value = "Thursday">Thursday <br>
<input name = "theDay" type = "checkbox" value = "Friday"> Friday<br>
<input name = "theDay" type = "checkbox" value = "Saturday"> Saturday<br>
</form>

<script type = "text/javascript">

(function( boxes )
{
  var today = new Date().getDay(),
      diff;

  for( var i = 0, len = boxes.length; i < len; i++ )
    boxes[i].disabled = ( diff = Math.abs( i - today )  ) > 1  && ( diff != len-1 ); 
 
})( document.getElementById( 'myForm' ).theDay )

</script>

</body>
Logic Ali is offline   Reply With Quote