going back 1 in index of checkbox
<p><a href="http://jsfiddle.net/thetylercox/LgxPn/27/" rel="nofollow">http://jsfiddle.net/thetylercox/LgxPn/27/</a></p>

<p>If I click 1 then 2 the checkbox is unchecked and an alert displays the problem is if I click 2 again no Alert! Im sure im storing the value of the previous check on 2 and i need to undo this! </p>

<pre><code>&lt;script&gt;
        $(function() {
            var lastChecked = [];
            $(':checkbox').change(function() {
                if (this.checked) {
                    if (lastChecked.length &amp;&amp; this.value != lastChecked[0].value) {  
   $(this).prop("checked", false)
                        alert("the last box you checked has a different value");
                    }
                    lastChecked.unshift(this);
                }
                else {
                    lastChecked.splice(lastChecked.indexOf(this), 1);
                }
            });
        });
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    1
    &lt;input type="checkbox" name="checkbox[]" onClick="getVal();setChecks(this)"  
  value="1" class="chk" id="chk&lt;?php echo $a++?&gt;"  title="&lt;?php echo 
 $rspatient['first'],' ',$rspatient['frameman'],' ', $rspatient['framemodel']?&gt;" lang="
  &lt;?php echo $rspatient['name']?&gt;"/&gt;&lt;br/&gt;
    2
    &lt;input type="checkbox" name="checkbox[]" onClick="getVal();setChecks(this)"  
  value="2" class="chk" id="chk&lt;?php echo $a++?&gt;"  title="&lt;?php echo  
  $rspatient['first'],' ',$rspatient['frameman'],' ', $rspatient['framemodel']?&gt;" 
  lang="&lt;?php echo $rspatient['name']?&gt;"/&gt;&lt;br/&gt;
</code></pre>

<p><a href="http://jsfiddle.net/thetylercox/LgxPn/27/" rel="nofollow">http://jsfiddle.net/thetylercox/LgxPn/27/</a></p>
