我想访问每个Html动态控件如下,每个控件都有Id Ref1_和Ref2_:
$('[id^="Ref1_"]').each(function () {
if ($(this).val().length > 0) {
var Temp = $(this).val() + ":" +$(this).parent().find("Ref2_").attr('id').split('_')[1];
Data += Sp + $(this).attr("id").split('_')[1] + ":" + $(this).val();
Sp = ',';
}
});
我想结合每个价值动态控制,但发现不工作
C#代码:
HtmlTableRow r = new HtmlTableRow();
HtmlTableCell CRef1 = new HtmlTableCell();
HtmlTableCell CRef2 = new HtmlTableCell();
HtmlInputText Ref1 = new HtmlInputText();
Ref1.ID = "Ref1_" + iSrl;
Ref1.Attributes.Add("dir", "ltr");
HtmlInputText ref2 = new HtmlInputText();
ref2.ID = "Ref2_" + iMSrl;
ref2.Attributes.Add("dir", "ltr");
CRef1.Controls.Add(Ref1);
CRef2.Controls.Add(ref2);
r.Controls.Add(CRef1);
r.Controls.Add(CRef2);
this.Table.Controls.Add(r);
答案 0 :(得分:0)
df <- data.frame(Tag = c(1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2),
YPred = c("L1", "L2" ,"L3", "L4", "L5", "L1", "L2", "L3", "L4", "L5"),
Long = c(1004 , 544 , 545 , 282 , 1 ,2068 ,3006 ,3711 ,2342 , 33),
Medium = c(108, 252, 211, 149, 0, 17, 110, 248, 341, 4),
short = c(58, 118, 131, 73, 4, 0, 43, 150, 189,2),
Urgent = c(5, 70, 65, 24 , 5 ,22 ,18, 31 ,96, 2))
&#13;
var Data='', Sp='';
$('[id^="Ref1"]').each(function () {
if ($(this).val().length > 0) {
//console.log($(this).attr("id")+ " : " + $(this).val() + " - Ref2" + $(this).parent().parent().find('[id^="Ref2"]').val());
var Temp = $(this).val() + ":" + $(this).parent().parent().find('[id^="Ref2"]').attr('id').split('_')[1];
Data += Sp + $(this).attr("id").split('_')[1]+ " : " + $(this).val() + "^" + $(this).parent().parent().find('[id^="Ref2"]').val();
Sp = ',';
}
});
console.log(Data);
&#13;
你可以试试这段代码
答案 1 :(得分:0)
`
<table id="Table">
<td>
<input name="Ref1_1330" type="text" id="Ref1_1330" dir="ltr"
value="2342" /></td>
<td>
<input name="Ref2_1330" type="text" id="Ref2_1330" dir="ltr"
value="23342" />
</td>
</tr>
<tr>
<td><input name="Ref1_1474" type="text" id="Ref1_1474" dir="ltr" />
</td>
<td><input name="Ref2_1474" type="text" id="Ref2_1474" dir="ltr" />
</td>
</tr>
</table>
`