如何使用jquery获取f_qty字段的值,并使用获得的每个值执行操作?
我有一个Html表单,它包含这个表“产品”,我需要在用户填写所有记录中的数量字段后,用户按下按钮开始扫描该表,并对每个值执行操作获得。 这是可能的还是我要求太多了如何使用jquery获取f_qty字段的值,并使用获得的每个值执行操作?,jquery,Jquery,我有一个Html表单,它包含这个表“产品”,我需要在用户填写所有记录中的数量字段后,用户按下按钮开始扫描该表,并对每个值执行操作获得。 这是可能的还是我要求太多了 <div class="Products" > <table width="100%" cellspacing="0" cellpadding="0" border="0"> <thead> <tr> <th class="left"&
<div class="Products" >
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr>
<th class="left">Product</th>
<th>Quantity</th>
<th>Precio</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="left">Product 1</a></td>
<td><input type="number" name="f_qty" min="1" max="9999" step="1" value="1"></td>
<td>35.17</td>
</tr>
<tr>
<td class="left">Product 2</a></td>
<td>
<input type="number" name="f_qty" min="1" max="9999" step="1" value="1">
</td>
<td>18.48</td>
</tr>
<tr>
<td class="left">Product 3</a></td>
<td>
<input type="number" name="f_qty" min="1" max="9999" step="1" value="1">
</td>
<td>4.00</td>
</tr>
<tr>
<td class="left">Product 4</a></td>
<td>
<input type="number" name="f_qty" min="1" max="9999" step="1" value="1">
</td>
<td>14.20</td>
</tr>
</tbody>
</table>
</div>
产品
量
普里西奥
产品1
35.17
产品2
18.48
产品3
4
产品4
14.20
嗨。我已经试过了,但是没有发生什么,在我的顶点字段上没有显示te值
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>jQuery Agregar Unidades</title>
<script type="text/javascript">
$("#someButton").click(
function(){
$("input[name=f_qty]").each(function(){
var valueInCurrentTextBox = $(this).val(); //take action here
valueInCurrentTextBox.add( 'P12_CANTIDAD_PEDIDO' , pThis.value);
});
}
);
</script>
</head>
<body>
<div id="default"></div>
<p style="clear: both;">
<button type="button" style="font-weight: bold; width: auto;" id="someButton">Agregar Unidades</button><p><span class="demoLabel"></span></p>
</body>
</html>
jQuery阿格雷加大学
$(“#someButton”)。单击(
函数(){
$(“输入[name=f_数量]”)。每个(函数(){
var valueInCurrentTextBox=$(this).val();//在此处执行操作
valueincirenttextbox.add('P12_CANTIDAD_PEDIDO',pThis.value);
});
}
);
阿格雷加大学
试试上面的方法。单击按钮时,它会遍历所有文本框可能需要
输入[name=f_qty]
添加选择器。当然,如果在同一页面上定义了其他输入框,我同意。更新。感谢您的快速回复。我将尝试并重新发布。!一个问题。此脚本是否会对我的html表单上的所有记录执行某种循环?提供的代码实际上并没有“执行”任何操作,它只是在变量valueInCurrentTextBox中为您提供值。之后由您来操作变量
$("#someButton").click(
function(){
$("input[name=f_qty]").each(function(){
var valueInCurrentTextBox = $(this).val(); //take action here
});
}
);