[ask] submitButton onclick

hello …

I want to ask, I put js in SubmitButton like the example below.




echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('onclick'=>'{displayDate();}')


 function displayDate()

		{

	   confirm("Price :"+$("#Batch_price").val() * $("#slot").val().length +"\nSlot:"+$("#slot").val()+"\n\n Are Your Sure??");

}



even if I click cancel, the form data was sent to the controller for the validation

how to make when clicking cancel does not happen anything?

What do you mean like this:




if(!confirm("Price :"+$("#Batch_price").val() * $("#slot").val().length +"\nSlot:"+$("#slot").val()+"\n\n Are Your Sure??")return false);



I tried code like this





echo CHtml::submitButton(

          	$model->isNewRecord ? 'Create' : 'Save',

          	array(

				 'ajax'=>array(

              	'type' => 'POST',

				  'url'=>CController::createUrl('dialog'),

				  'data'=>array('price'=>'js:$(\'#Batch_price\').val()',

								'slot'=>'js:$(\'#slot\').val()',

				  ),

				'success'=>'js:

            	function(id){  

              	confirm(id);

					}',

          	),

			));




I managed to bring up a pop-up message with the attribute of the form

but i can not save data into the database …

please help meee…:mellow:

use Firebug (firefox plugin) to check response data from server :)