开发者

calling of javascript function on button click in .module file in drupal

I have one button and onclick i want javascript function to be called which contains alert message...............in drupal

i tried many things like........... 1)i created button using

$form['click'] = array( '#type' => 'button', '#attributes' => array('onclick' =>_____________),//dnt know what to give for onclick '#value' => t('click'), );

2)used drupal_add_js(drupal_get_path('module', 'document').'/eg.js', 'module');in hook_form_alter()

3).js file is as follows function message() { alert("Catch ->This alert box was called"); } -->

w开发者_运维百科ant alert message to be displayed on button click. Kindly help................ Thanks in advance


$form['search_something'] = array(
      '#type' => 'button',
      '#value' => t('Search'),
      '#attributes' => array('onclick' => 'searchsomething()),
  );

this is the piece of code to call javascript on button click.

Javascript function

function searchsomething(){
  alert("hello");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜