Yii Framework Forum: add js function to sunbitButton - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

add js function to sunbitButton Rate Topic: -----

#1 User is offline   evoup 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 14-July 10

Posted 14 July 2010 - 06:26 AM

hello,
i want to add a js function in the submitbutton
<?php echo CHtml::submitButton(Yii::t($ss, 'next'));?>

like this
<input type=submit value=next onclick="jsfunction()">

how can i do it?
0

#2 User is offline   petra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 20-June 10

Posted 14 July 2010 - 06:31 AM

use the htmlOptions parameters
http://www.yiiframew...itButton-detail

<?php echo CHtml::submitButton(Yii::t($ss, 'next'), array('onclick' => 'jsfunction()'));?>


or you could use the jquery

<?php
Yii::app()->clientScript->registerCoreScript('jquery.js');
Yii::app()->clietnScript->registerScript('function', '
    $(\'#submitbutton\').click(function(){
        //do somefunctions
    });
');

//
echo CHtml::submitButton(Yii::t($ss, 'next'), array('id' => 'submitbutton'));

2

#3 User is offline   evoup 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 14-July 10

Posted 14 July 2010 - 06:38 AM

good~thks
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users