yii - how to get one of the input textfield value through ajaxbutton -


how user's input value , submit ajax controller? right now, in controller says id undefined index in $_post['id']

this input textfield within form, kind of form inside form.

<?php echo $form->textfield($model,'email',array('id'=>'email')); ?>         <?php echo $form->error($model,'email'); ?>           <?php echo chtml::ajaxbutton ( 'request code',                  chtml::normalizeurl(array('site/requestresetcode', 'render'=>true),                 array (                     'type' => 'post',                     //'data'=> array('id'=> 'js:$("#resetpasswordform_email").val()'),                     'data'=> array('id'=> 'js:$("#email").val()'),                     'success'=>'function(data){                         if(data.status == "sent")                             bootbox.alert("code sent. please check email.");                         else (data.status == "failed")                             bootbox.alert("request failure");                         }',                     'error'=> 'function (xhr, ajaxoptions, thrownerror) {                         alert(xhr.status);                         alert(thrownerror);                         }',                 )             ))         ?> 

controller:

public function actionrequestresetcode()     {         $id = $_post['id']; //stuff.. 

your post array empty because value not being sent. need make javascript function like

<script type="text/javascript">      function getval()     {      var value= $("#myemail").attr('value');     alert(value);     return value;      }     </script> 

check if alert shows correct value remove alert statement. if not show value there problem id of textfield.
if working use like

 'data'=> array('id'=> 'js:getval()'), 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -