Last active
February 1, 2017 09:52
-
-
Save MiquelAdell/131f9b6931b0d3c1fbcfa38cb86f3c62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready(function() { | |
var lock = false; // variable to lock changes while running the function; | |
$('#question'+{QID}+' input:checkbox').change(function(event){ | |
if( lock ){ | |
event.preventDefault(); | |
return; | |
} | |
var checkbox = $(this); | |
var td = checkbox.closest('td'); | |
var tr = td.closest('tr'); | |
if( td.index() === 1 ) { | |
// is the first checkbox | |
lock = true; | |
tr.find("input:checkbox").each(function(){ | |
// this will loop all the checboxes from the row | |
// if is not the first one uncheck it | |
if( $(this).closest('td').index() !== 1 ){ | |
$(this).prop('checked', false); | |
$(this).closest('td').find("input:hidden").val(""); | |
} | |
}); | |
lock = false; | |
} | |
else { | |
// is not the first checkbox | |
// we should remove the check from the first checkbox only | |
lock = true; | |
tr.find('td').first().find("input:checkbox").prop('checked', false); | |
tr.find('td').first().find("input:hidden").val(""); | |
lock = false; | |
} | |
}); | |
}); | |
</script><strong>Indiqueu si heu realitzat alguna de les següents accions i, en cas que així sigui, amb qui</strong> <strong>Indiqueu si heu realitzat alguna de les següents accions i, en cas que així sigui, amb qui</strong> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment