JavaScript gets the line content of the GridView selection _javascript tips
Source: Internet
Author: User
The choice of these things is first to find out what line is selected, as follows:
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;
}
}
Take to the value in the textbox
Table.rows[rowindex].cells[3].getelementsbytagname ("input") [0].value
Take the value in the lable
Table.rows[rowindex].cells[4].getelementsbytagname ("span") [0].innerhtml
The back of the. innerHTML can be replaced by. innertext, but. innerHTML browser compatibility is better.
(Note here: whether it's using. innerHTML or. innertext is only to display information between <span>XXXX</span>, rather than as a textbox label displayed in <input value= " XXXX "></input>. The disadvantage is: the page will not be refreshed. )
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.