2012-11-05 100 views
0

我怎样才能设置隐藏字段数组的值内隐藏字段阵列

$('#addbutton').click(function() { 
     var txt = "<tr id='divs'><td><input type='hidden' id='hids[]' name='hifld' /> </td></tr> "; 
     $('#systemconfig').append(txt); 

     var dd = $("#hid").attr("value"); 
     var inthidden = parseInt(dd); 
     var vl = parseInt(dd, '0') + 1; 
     $("#hids[]").attr("value", vl); // this is not working 
+0

'hids []'甚至是一个有效的ID? – Hubro

+1

ID属性必须是唯一的,'name =“hids []”'将是有效的,但不在ID属性的情况下,因为ID必须是唯一的。 – Nelson

回答

1

你的ID不能为阵,你的名字可以..

所以你的ID应该像hids和你的名字一样hifld[],然后分配像

$("#hids").val(vl); 
0

尝试.VAL的设置ID()代替:

$("#hids[]").val(v1)