我正在创建一个有多个答案的调查问题。
有一个按钮
可以克隆现有的文本框
。
但是,我如何获取这些克隆的文本框的值,尤其是从代码隐藏中获取的值。
这是我的代码:
function generateRow() {
if (totalans == 9) {
$('#<%= label2.ClientID %>').html('<b>Maximum of 10 answers per questions reached</b>');
}
else {
$("#ans").clone().prependTo("#ans2");
totalans = totalans + 1;
}
//#ans 是除法。
谁能帮帮我。 我试图得到它。
//c#代码隐藏
String bla = tb_ans.ToString();
String[] splitAnswer = bla.Split(',');
int a = splitAnswer.Length;
//tb_ans 是我的文本框 ID。
我尝试使用数组,但似乎只采用了第一个 textbox
值,而转储了其他值。
最佳答案
查看您的评论后,我修改了我的答案:
function generateRow() {
if (totalans == 9) {
$('#<%= label2.ClientID %>').html('<b>Maximum of 10 answers per questions reached</b>');
}
else {
totalans = totalans + 1; // same as totalans++;
$("#ans").clone().attr({id: "ans_clone_" + totalans, name: "ans_clone_" + totalans}).prependTo("#ans2");
// then you can loop through each input using the totalans variable.
}
关于jquery - 如何获取 jquery 克隆文本框的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8402268/