I need to call the gh_cart_prove when the BUTTON is clicked.
function gh_view_categories(){
$a='<table>';
$a.='<tr>';
$a.='<td><strong>'.'Categoria:'.'</strong></td>';
$a.='<td><strong>'.'Soglia minima:'.'</strong></td>';
$a.='<td><strong>'.'Tot attuale:'.'</strong></td>';
$a.='<td><strong>'.'Crea ordine'.'</strong></td>';
$a.='</tr>';
$query = db_select('uc_product_classes', 'u')
->fields('u', array('name','soglia', 'totattuale'));
$result = $query->execute();
while ($record = $result->fetchAssoc()) {
$idUser=gh_get_user_id($record['name']);
$a.='<tr>';
$a.='<td>'.$record['name'].'</td>';
$a.='<td>'.$record['soglia'].'</td>';
$a.='<td>'.$record['totattuale'].'</td>';
$a.='<td>'.'<button onClick="gh_cart_prove($idUser)">BUTTON</button>'.'</td>';
$a.='</tr>';
}
$a.='</table>';
return ($a);
}
The button appear but it not works. the function is correctly declared. How can I resolve this problem?
gh_cart_prove()
a JavaScript function?gh_cart_prove()
as a PHP function in a contributed module? What I don't see here is a <form> element. If you want to handle it like a form, I would recommend placing one in your table (even if it's within your existing <td>). Otherwise, Javascript would be your best approach.