【问题标题】:Call a function from a "html table" in drupal 7从 drupal 7 中的“html 表”调用函数
【发布时间】:2015-09-28 08:31:43
【问题描述】:

单击按钮时我需要调用函数。我怎么能做到这一点? (我知道我写的代码是错误的,只是为了说清楚)

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>'.l('BUTTON', FUNCTION($idUser)')).'</td>';
    $a.='</tr>';
  }

  $a.='</table>';
  return $a;
}

【问题讨论】:

    标签: php module drupal-7


    【解决方案1】:

    你需要在你的html按钮标签中添加这个:

    &lt;button onClick="yourFunction()"&gt;

    【讨论】:

    • 谢谢,我已经添加了这段代码,按钮出现了,但它不起作用。
    • 我不知道为什么它不会,您是否在控制台中收到任何错误?函数的名称对吗?您的功能是否正确且没有错误?
    • 该按钮是可点击的,但没有任何反应。我尝试了一个非常简单的函数 uc_cart_prova function() { echo ('OK');返回(“确定”); }
    • 好吧,我需要先查看所有代码,然后才能进一步帮助您
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多