摘要:checkbox依據取其它欄位的值判斷是否checked
<input type="checkbox" id="Checkbox0" name="Check0" onclick="selectall()" />
...................................js..............................................
function selectall(){
var selectAll =$("#Checkbox0").attr('checked');
if(selectAll){
$("input[name='chkbox']").each(function(index) {
if ($(this).attr("VERIFYRESULT") == "清查成功,驗簽通過,檔案均存在。"){
$(this).attr("checked", true);
} else {
$(this).attr("checked", false);
}
});
// $("input[name='chkbox']").attr("checked",true);
}else{
$("input[name='chkbox']").attr("checked",false);
}
}
多個checkbox:
<input id="chkbox" name="chkbox" type="checkbox" onclick="chkVerify(this)">
<xsl:attribute name="value">
<xsl:value-of select="COLUMN[@NAME='RECENO']" />
</xsl:attribute>
<xsl:attribute name="VERIFYRESULT">
<xsl:value-of select="COLUMN[@NAME='VERIFYRESULT']" /> //值為"清查成功,驗簽通過,檔案均存在。"
</xsl:attribute>
</input>
...................................js..............................................
function chkVerify(obj){
var strVerify = obj.attributes['VERIFYRESULT'].nodeValue;
if(obj.checked) {
if (strVerify == "清查成功,驗簽通過,檔案均存在。"){
obj.checked = true;
} else {
obj.checked = false;
}
}
//alert('t:' + $(this).attr("checked"));
}