2
这是单行样本列在这里我试图通过按钮操作事件以获取隐藏的价值获取多个输入型隐藏价值排按钮,点击列在表
<td colspan="2">
<!-- the hidden value i want to retrieve "stockitemid" and "outletid" -->
<!-- value i have bind from controller through model like @item.ID= stockitemid and @item.OUTLET_ID=outletid -->
<input type="hidden" class="itemid" name="stockitemid" value="@item.ID"/>
<input type="hidden" class="oid" name="outletid" value="@item.OUTLET_ID"/>
<div class="btn-toolbar row-action">
<div class="btn-group pull-right">
<!-- button action given below what i have tried to display value in modal form controller. but every-time i click same value found from this event -->
<button class="btn btn-primary" id="btnitemaddtotray" data-toggle="modal" data-target="#addtotrayModal" title="Add Item"></button>
</div>
</div>
</td>
Hhere每次都是我的检索jQuery代码我得到相同的“stockitemid”和“不合格”
<script>
$('#btnitemaddtotray').click(function() {
// this is what i have tried to get row index with column index value
$('td').click(function() {
var col = $(this).parent().children().index($(this));
var row = $(this).parent().parent().children().index($(this).parent());
alert('Row: ' + row + ', Column: ' + col);
});
// here is itemid and outlet id i got every-time same value.
var itemid = $('input[name=stockitemid]').val();
var outletid =$('input[name=outletid]').val();
});
</script>
我想从表中获得隐藏值,我有多行。
你不能有一个'。点击()'处理程序中的'。点击()'处理程序。而suplicare'id'属性是无效的html。改为使用类名称。 - '$('。btn')。click(function(){var cell = $(this).closest('td'); var itemid = cell.find('。itemid')。val(); 。});' –
非常感谢你。 –