Given the following which creates a set of checkboxes:
$db =& P4A_DB::singleton();
$clientlist = array();
$items = $db->fetchAll("SELECT * FROM microsites WHERE status=1 ORDER BY sitetitle");
foreach ($items as $item) {
$ci = $item['user'];
$cd = $item['sitetitle'];
$clientlist[] = array('id' => $ci, 'desc' => $cd);
}
$client_array_source =& $this->build("p4a_array_source", "client_array_source");
$client_array_source->load($clientlist)
->setPk("id");
$selectallbutton = $this->build("p4a_button","selectallbutton")
->setLabel('Select All');
$this->intercept($selectallbutton, 'onClick', 'selectall');
$this->build("p4a_field","clients")
->setWidth(300)
->setType("multicheckbox")
->setSource($client_array_source)
->setSourceDescriptionField("desc")
->setSourceValueField("id");
This function will allow the user to click the "select all" button and have their checkboxes populated:
function selectall() {
$array_id = array();
$num_rows = $this->clients->data->getNumRows();
for ($i = 1; $i $#60;= $num_rows; $i++) {
$this->clients->data->row($i);
$array_id[$i] = $this->clients->data->getPkValues();
}
$this->clients->setNewValue($array_id);
$this->clients->load();
}
This works in P4A v3.4.1 but not 3.4.0. I've not tested on later versions.
http://www.fearofmice.co.uk/blog/htsrv/trackback.php?tb_id=44
No Comments/Trackbacks/Pingbacks for this post yet...
Comments are not allowed from anonymous visitors.
This is the official blog of

We aim to post comments (and possibly solutions) to some of the more interesting IT Support issues we come across in our daily travels around the South Hams of Devon.
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| << < | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||