I need to get value of according to checked checkbox... using HTML and JQuery or Javascript i have tried following code:
JQuey Code:
<script type="text/javascript">
$(function () {
$('input:not(#submit)').click(function () {
t = $(this).attr('id');
text = $('.time' + t).text();
//alert(text);
});
$('#submit').click(function (e) {
e.preventDefault();
var trs = $('table tr');
var values = trs.first().find('td');
var values1 = $('table tr td :checkbox:checked').map(function () {
return $(this).closest('tr').find('td').text() + "==>"
+ values.eq($(this).parent().index()).text();
}).get();
alert(values1);
});
});
</script>
HTML Code:
<body>
<table border="1">
<tr>
<td>No</td>
<td >Name</td>
<td >City</td>
<td >Check</td>
</tr>
<tr>
<td>1</td>
<td>
select</td>
<td>
select</td>
<td>
<input type="checkbox" name="checkbox" class="r1" />select</td>
</tr>
<tr>
<td>2</td>
<td>
select</td>
<td>
select</td>
<td>
<input type="checkbox" name="checkbox" class="r1" />select</td>
</tr>
<tr>
<td>3</td>
<td>
select</td>
<td>
select</td>
<td>
<input type="checkbox" name="checkbox" class="r1" />select</td>
</tr>
<tr>
<td>4</td>
<td>
select</td>
<td>
select</td>
<td>
<input type="checkbox" name="checkbox" class="r1" />select</td>
</tr>
</table>
<input type="submit" name="submit" id="submit" value="Save time sheet" />
</body>
I need to get value of of any row which checkbox is checked and i require multiple values also if multiple checkboxes are checked...
Aucun commentaire:
Enregistrer un commentaire