Passing in a form value via ajax. Ajax Submit Button


<div class="areaTxt"><textarea name="comments" cols="" rows="4" class="txtArea"></textarea>

  <div class="txtRht">

    <?php

		echo CHtml::ajaxSubmitButton(

                                        'Reply',

                                        array('eventdiscuss/addDiscussion?id='.$model->id.'&user_id='.Yii::app()->user->id.'&message='COMMENTS.VAL() I WANT HERE),

How would I go about passing the value of comments into that ajax submit button.

Better Yet:




better yet:


array('data'=>"&message=+js:jQuery('#comments').val()+&id=1",

 



how can I fix this, message is not being set.

Thank You.

I would go this way:

http://www.yiiframework.com/forum/index.php/topic/28883-form-submission-by-dynamically-added-button/page__view__findpost__p__139445

Hey Bettor,

Thank you for taking the time to get back to me. Can you do me a favor and show me full code example of where to put it? Do declare a <script type="text/javascript"> and put it in it? or do I put it in the php side?

Also can you show me the code for the form?

Thanks,

I place the jquery code in a separate file and include it in the respective action where it’s called like:

Yii::app()->clientScript->registerScriptFile("path/name.js");

The form can be any Yii generated form as far as the submit button has id and in the jquery code you capture this id value in the portion input[id="your id name here"];

Give it a try and let me know what works and what not and I will try to help you further.