How to Get Checked Row Data Using Java Script

                                                                                                                                                                                  <!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Anand"/> </td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Ajeet"/> </td>
</tr>

<tr>
<td>Shabbir Hussein</td>
<td>8</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Antrish bhai"/> </td>
</tr>
<tr>

<td>Shabbir Hussein</td>
<td>9</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Test"/> </td>
</tr>
</table>

<input type="submit" onclick="Run()">

<script type="text/javascript">
function  Run(){
var lineitemscheckbox = document.getElementsByName('lineitemsCheckBox');
for (var i = 0, len = lineitemscheckbox.length; i < len; i++) {
        if (lineitemscheckbox[i].checked) {
            //alert("checked " + lineitemscheckbox[i].value);
            //lineitemskey[i] = lineitemscheckbox[i].value;
            temp = lineitemscheckbox[i].value;
         // alert("===>"+temp);
 }
 }
}
</script>


</body>
</html>  
<%--In Dymanic value you can passit Like
<input type='checkbox' name='lineitemsCheckBox' id='lineitemsCheckBox' value='"+finalMessage+ "'/>
-->

Comments

Post a Comment

Popular posts from this blog

Converting JSONArray into CSV file in java

Java Design pattern

Map class field to map