<HTML><Headrunat= "Server"> <title>Demonstrates getting the value of a table</title> <Scripttype= "Text/javascript"language= "JavaScript" > //Description: Demo uses JavaScript to get the values of the specified row and column elements in the table //copyright:http://www.cnblogs.com/yangmingming //Notes: Use simple table and combine with TextBox to get functionGetTable23 () {vartxt=document. getElementById ("Txtreceiver"); //First: The TD element with the tag ID to get the value methodtxt. Value=document. getElementById (" at"). InnerHTML; //The second is to specify the fetched row, column, using the Get table (through its ID) varvaluetd=document. getElementById ("TBL"). Rows [1].cells[2]; Txt.value=valuetd.innerhtml; } </Script></Head><Body> <formID= "Form1"runat= "Server"> <Div> <Tablestyle= "width:100%;"ID= "TBL"> <TR> <TD> One</TD> <TD> A</TD> <TD> -</TD> </TR> <TR> <TD> +</TD> <TD> A</TD> <TDID= "All"> at</TD> </TR> <TR> <TD> to</TD> <TD> +</TD> <TD> -</TD> </TR> </Table> <Asp:textboxID= "Txtreceiver"runat= "Server"></Asp:textbox> <inputID= "Btnsubmit"type= "button"value= "Get"onclick= "GetTable23 ()"; /> </Div> </form></Body></HTML>
Its debug results are:
We can see the value of the second and third columns as expected.
Use JavaScript to get the row, column, and rows specified in table