源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JavaScript获取GridView选择的行内容

  • 时间:2020-11-30 10:56 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JavaScript获取GridView选择的行内容
这些东西的选取首先就要找出选择的是第几行,如下: var table = document.getElementById("<%=GridView1.ClientID %>"); var rowIndex = 0 ; for(var i=1;i<table.rows.length;i++) { var input = table.rows[i].cells[0].getElementsByTagName("input")[0].checked; if (input == true) { rowIndex = i; return rowIndex ; } } 取到TextBox中的值 table.rows[rowIndex].cells[3].getElementsByTagName("input")[0].value 取到Lable中的值 table.rows[rowIndex].cells[4].getElementsByTagName("span")[0].innerHTML 后面的.innerHTML可以换成.innerText,不过.innerHTML的浏览器兼容性好些。 (这里要注意了:不管是用.innerHTML还是.innerText都是只把信息显示<span>XXXX</span>之间,而不是像TextBox的标签显示在<input Value="XXXX"></input>中。缺点是:页面一刷新就没有了。)
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部