I've created a table by using CGridView, inside the table contain input text field which allow user to insert value. The issue is I can get the text from the table where there is no input field, but not with the one that contain input field.
Php:
<?php
$this->widget('zii.widgets.grid.CGridView',array(
'id' => 'oc-list-upgradeRule',
'dataProvider' => $upgradeRuleDataProvider,
'selectableRows' => 2,
'summaryText' => '',
'columns' => array(
array(
'header' => '',
'id' => 'chkbox',
'name' => 'checkBox',
'class' => 'CCheckBoxColumn',
),
array(
'header' => 'Min. Spending Amount',
'id' => 'minSpendingAmount',
'name' => 'minSpendingAmount',
'type' => 'raw',
'value' => 'CHTML::textField("",$data["minSpendingAmount"],array())',
'htmlOptions'=>array(
'style'=>'text-align: center;'
)
)
)
));
?>
Javascript:
$(document).on('change', 'input', function () {
var upgradeRenewDowngrade = $('.oc-upgrade-renew-downgrade');
upgradeRenewDowngrade.find('.oc-save-upgrade-downgrade-rules').click(function (e) {
var sel = $.fn.yiiGridView.getChecked('oc-list-upgradeRule', 'chkbox');
var row = $.fn.yiiGridView.getRow('oc-list-upgradeRule', sel);
var minSpendAmount = row.get(5);
var input = $(minSpendAmount).html();
//console.log($(input).val());
console.log(minSpendAmount);
})
})
From the code above, I only able to get td together with input text field.
<td style="text-align: center;">
<input type="text" value="365" name id>
</td>
How to get the input text value? You may suggest other way to get the value from CGridView. Thanks.
Ok, so…
Playing a little with your code, I ended up with this:
// Here, I only set my variable to be the same as yours var minSpendAmount = '<td style="text-align: center;"> <input type="text" value="365" name id></td>'; // Code you may do instead of your current console.log(minSpendAmount) var input = $(minSpendAmount).html(); console.log($(input).val());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Tell me if that helps you, or not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.