Php 使用Jquery、codeignighter更改特定的span标记值
我有一个表单,它包含一个表,其中有3个输入,每行一个跨度。第一个输入是产品名称。当它被填充并失去焦点时,我正在使用一个ajax post函数来获取我手头的数量。然后我需要将该值放入跨度中。问题是,这些行中可以有超过100行是动态添加的,我已经尝试过像这样使用.next()了( 这是jqueryPhp 使用Jquery、codeignighter更改特定的span标记值,php,jquery,codeigniter,dom,Php,Jquery,Codeigniter,Dom,我有一个表单,它包含一个表,其中有3个输入,每行一个跨度。第一个输入是产品名称。当它被填充并失去焦点时,我正在使用一个ajax post函数来获取我手头的数量。然后我需要将该值放入跨度中。问题是,这些行中可以有超过100行是动态添加的,我已经尝试过像这样使用.next()了( 这是jquery $( document ).ready(function () { // set an on click on the button $('input[id^="products"]').blur
$( document ).ready(function () {
// set an on click on the button
$('input[id^="products"]').blur(function () {
var productName = $(this).val();
$.ajax({
type: "POST",
url: "<?php echo site_url('autocomplete/get_info'); ?>",
dataType: "json",
data: {productName:productName},
success: function(msg){
$('span[id^="qoh"]').html(msg);
}
});
});
});
$(文档).ready(函数(){
//在按钮上单击设置
$('input[id^=“products”]”)。模糊(函数(){
var productName=$(this.val();
$.ajax({
类型:“POST”,
url:“”,
数据类型:“json”,
数据:{productName:productName},
成功:函数(msg){
$('span[id^=“qoh”]”)html(msg);
}
});
});
});
下面是Codeignighter创建的表单和表
<?php echo form_open('transactions/transaction_review'); ?>
<div class="form_settings">
<p><?php
$attributes = array(
'sales_reciept' => 'Sales Reciept',
'invoice' => 'Invoice'
);
echo form_dropdown('transaction_type', $attributes); ?></p>
<p><?php echo form_dropdown('customer', $customerName); ?></p>
<table id="product_table" style="width:100%; border-spacing:0;">
<tr>
<th>
Product Name
</th>
<th>
Description
</th>
<th>
Quantity
</th>
<th>
Quantity On Hand
</th>
<th>
Price
</th>
</tr>
<?php
for($index = 1; $index <= $product_num; $index++)
{
echo ' <tr id="product_info' . $index . '">
<td rowspan="1">' . form_input('product' . $index, 'Product', 'class="class-1" id="products"') . '</td>
<td rowspan="1">' . form_input('description' . $index, 'Description', 'class="class-1" ') . '</td>
<td rowspan="1">' . form_input('quantity' . $index, 'Quantity', 'class="class-1"') . '</td>
<td rowspan="1"><span id="qoh' . $index . '">0</span></td>
<td rowspan="1">' . form_hidden('ctrl' . $index, 'ctrl') . '</td>
</tr>';
}
echo form_hidden('index', $index, 'id="index"');
?>
</table>
<table id="tender_info">
<tr id="">
<td><?php echo form_input('elements', '0', 'id="elements"'); ?>
</td>
<td></td>
<td></td>
<td><p style="text-align: right"></p></td>
<td><?php echo form_input('sub_total', '0.00', 'class="subtotal"'); ?></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td><?php echo form_dropdown('paymentType', $payment_type); ?></td>
<td><?php echo form_input('paymentAmount', 'Total', 'class="total"'); ?></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td><?php echo form_input('discountAmount', 'discountAmount', 'class="class-1"'); ?></td>
</tr>
</table>
<p><?php echo form_input('note', 'note'); ?></p>
<?php echo form_hidden('status', 'status'); ?>
<p style="padding-top: 15px"><?php echo form_submit('submit', 'Create Transaction'); ?></p>
</div>
</div>
<?php echo form_close(); ?>
品名
描述
量
现存量
价格
更改以下几行并尝试一下(我这里没有给出全部代码,只是给出了要更改的几行代码),希望它能起作用:
<td rowspan="1">' . form_input('product' . $index, 'Product', 'class="class-1 prods" id="products_'.$index.'"') . '</td>
<td rowspan="1"><span id="qoh_' . $index . '">0</span></td>
$('.prods').blur(function () {
$('qoh_'+productName).html(msg);
”。形式为“输入('product'.$index','product','class=“class-1 prods”id=“products'.$index.”)。”
0
$('.prods').blur(函数(){
$('qoh\'+productName).html(msg);