yeowza
Posts: 16
|
| Posted: 01/07/2009, 11:43 AM |
|
I had to create a function to try and format checkboxlists. I have an advanced search I created that has a large number of checkboxlists on the page. I needed a way to format them all easily since a single line list didn't work. I wrote this function. It works so I thought I would pass it along. I'm sure it could be improved.
I name all of my checkboxes sequentially.
In the beforeshow for the page I add these calls. The first parameter is the value to append to the checkbox name. The 2nd one is the number of columns you want in a line.
formatchecklistx("1",5);
formatchecklistx("2",5);
formatchecklistx("3",6);
formatchecklistx("4",6);
Then add this function in the page code.
function formatchecklistx($num,$col){
global $tblresumeSearch; //Compatibility
$list = "CheckBoxList".$num;
$label = "Label".$num;
$val = "<table><tr><td>";
$tblresumeSearch->$label->SetValue($val);
$cnt = count($tblresumeSearch->$list->Values);
$inc = 1;
for ($i = 0; $i<$cnt; $i+=$inc) {
$c2 = $i + 1;
$val = "</td>";
if ($c2 == $cnt){
$val .= "</tr></table>";
} else {
if ($col > 0) {
$rem = $c2 % $col;
} else {
$rem = 0;
}
if ($rem == 0) {
$val .= "</tr><tr><td>";
} else {
$val .= "<td>";
}
}
$tblresumeSearch->$list->Values[$i][1] .= $val;
}
}
|
 |
 |
|