Jquery实现动态添加行。前台添加,后台取值

脚本

<script type="text/javascript">

function RemarksAppend() {

var i = 6;
var textname = "textname";
var appendvalue = "<div><input type='text' name=" + textname + " style='width:600px' class='texvalue' /><input class='del-text' type='button' value='Delete'/></div>";

var ma = $('#main').append;
ma = $('#main').append(appendvalue);
$('#<%=hfRemarks.ClientID %>').val($('#main').html());
}
$(function () {
$('.del-text').live('click', function () {
$(this).parent().remove();
});
});
function getRemarkValue() {
var result = "";
$("input[name='textname']").each(function () {
result = result + encodeURI($(this).val()) + "|";
});
$('#<%=HFRemarksResult.ClientID %>').val(result);
}
</script>

前台页面

<div>
<div />
</div>

后台

protected void btnShow_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(HFRemarksResult.Value))
{
string[] hfRemarksResult = HFRemarksResult.Value.TrimEnd('|').Split('|');
if (hfRemarksResult.Length > 0)
{
int no = 1;
string Remark = string.Empty;
foreach (string a in hfRemarksResult)
{
Remark += Server.UrlDecode(a);
no++;
}

btnShow.Text = Remark;
}
}
}

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-12-10
  • 2022-02-23
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案