Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:30:05+00:00 2026-06-10T18:30:05+00:00

Q : how to add a data value into the label of table’s row

  • 0

Q : how to add a data value into the label of table’s row by ajax?

status : add a new row into table of form is working. at then, when the user choose the item, the price should be show at the label(price). return from controller is fine. but the price didn’t show at label(price).

This is my view

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'acc-recei-form',
    'enableAjaxValidation'=>false,
)); ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>
   <?php
    Yii::app()->clientScript->registerScript('add-item', "
        $('#add-item').click(function(){
            //console.log(item_template);
            $('#template .template_item').clone().appendTo('#item_list');
            $('#item_list .template_item').fadeIn();
            return false;
        });

        $('#AccRecei_acc_category_id').live('change', function(){
                                                               var itemID = $(this).val(),
                    vNode  = $(this);
                    $.ajax({
                  url: 'getitem/'+itemID,
                  dataType: 'json',
                  success: function(data){
                    var target = $(vNode).parents('tr');
                    alert(target);
                    $(target).find('.price').val(data.item_price);
                  }
                });
                //alert(vNode);
            });
");


    ?>
<table id="item_list">
<tr>
    <td>name</td>
    <td>price</td>
    <td>qty</td>
    <td>row_total</td>
<tr>
</table>
<!--- other fields -->

<div class="row buttons">
    <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<table id="template" style="display:none;" >
<tr class="template_item">
    <td><?php
            echo $form->dropDownList($model,'acc_category_id', $accitemslist, array(
            'prompt'=>'Please select a category',
            'options'=>array("$model->acc_category_id"=>array('selected'=>'selected')),
            )
        ); 
        ?></td>
    <td><label id="price" class="price"></label></td>
    <td><input type="text" name="item_qty[]" class=".qty" /></td>
    <td><label id="row_total" class="row_total[]"></label></td>
<tr>
</table>

This is the controller (call from ajax)

public function actionGetitem()
    {
        echo CJSON::encode(array(
            'item_price'=>12, 
        ));
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:30:07+00:00Added an answer on June 10, 2026 at 6:30 pm

    a ‘label’ tag doesn’t have a ‘value’. Try using ‘text()‘ instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While trying to add value into foreign key field, if same data doesn't exist
I got this parameter: $objDbCmd.Parameters.Add(@telephone, [System.Data.SqlDbType]::VarChar, 18) | Out-Null; $objDbCmd.Parameters[@telephone].Value = $objUser.Telephone; Where the
I want to use echo to add data into a text file progressively. I
I'd like my web page to allow the user to add data, even when
my function puts the correct value into the form for my view but doesn't
I'm trying add data triggers to the default combobox style so each text item
HI How do i add data using wcf rest architecture. I dont want to
i want to add data to listview but my data are as String[] and
I have a db where I manually add data. Some of the fields are:
I have a WPF DataGrid that increases in height when I add data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.