I want to get only textbox value where checked by checkbox, all textbox and checkbox from database array.
<tr><?php foreach($arrbook as $book) { ?> <td><input type="checkbox" name="book" class="book" value="<?php echo $book['id_book']; ?>"/> <?php echo $book['name_book'];?></td> <td><input type="text" name="bookprice"class="bookprice" value="<?php echo $book['book_price']; ?>"/</td> <?php } ?></tr> <td><div class="button"><a href="#" onClick="submitbookdata();">Save !</a></div></td></tr>
<script>
function submitbookdata() {
var bookidArr = [];
var bookpriceArr = [];
$('.book').each(function() {
if (this.checked) {
var current = $(this).val();
$(this).parents("tr").find(".bookprice").each(function)(index, n) {
if ($.each('n').val() == current) {
bookpriceArr.push(this.value);
}
});
}
bookidArr.push($(this).val());
});
alert(bookpriceArr);
}
</script>
Aucun commentaire:
Enregistrer un commentaire