Subject: | Patch to set checkbox value |
This patch allows setting a checkbox's state using the result of a
server-side function. Note that this uses Javascript's boolean
interpretation rules, not Perl's.
--- c:\perl\site\lib\CGI\Ajax.pm Tue Dec 11 21:20:04 2007
+++ lib\CGI\Ajax.pm Tue Dec 11 21:20:00 2007
@@ -923,7 +923,9 @@
var div = document.getElementById(dt[i]);
if (div.type =='text' || div.type=='textarea' ||
div.type=='hidden' ) {
div.value=data[i];
- } else{
+ } else if (div.type =='checkbox') {
+ div.checked=data[i];
+ } else {
div.innerHTML = data[i];
}
}