Js gets a checkbox to check whether it is selected. jscheckbox
<Script language = javascript> function check () {var xz = document. getElementById ("xz"); alert (xz. checked) ;}</script>
How can I use js to determine whether a check box is selected?
Var chk = document. getElementById ('checkbox id'); if (chk. checked) {// submit} else {// do not submit}
How does js obtain the tr of the selected checkbox line?
<Html>
<Head>
<Title> check box </title>
<Script type = "text/javascript">
Function del (){
Var tb = document. getElementById ("tb ");
If (tb. rows. length <2 ){
Return;
}
Var row;
Var cell;
Var chk;
// Less processing can be performed during iteration.
For (var I = tb. rows. length-1; I> 0; I --) {// If You Want To iterate the first line (I>-1)
Row = tb. rows [I]; // iterate the current row
Cell = row. cells [0]; // cell where the check box is located
Chk = cell. getElementsByTagName ("input") [0]; // indicates the number of INPUT elements in the cell.
If (chk. checked) {// if selected
Tb. deleteRow (I); // Delete and change rows
}
}
}
Var html;
Function reTB (){
Document. getElementById ("contentDiv"). innerHTML = html;
}
Window. onload = function (){
Html = document. getElementById ("contentDiv"). innerHTML;
}
</Script>
</Head>
<Body>
<Input type = "button" value = "delete selected row" onclick = "del ()"/>
<Input type = "button" value = "refresh" onclick = "reTB ()"/>
<Div id = "contentDiv">
<Table id = "tb" width = "250px" border = "1px">
<Tr> <td style = "width: 20%"> <input type = "checkbox"/> </td> <td style = "width: 40% "> name </td> <td &...... remaining full text>