4
Good morning
I created a shopping list with checkbox and would like to print only the selected checklists.
follow the codes below:
html code
<div class="cont-list carnes">
<h3 class="text-center"><span>Carnes / Aves / Peixes</span></h3>
<div class="col-md-3">
<input value="lombo" type="checkbox" /><label>Lombo</label>
</div>
<div class="col-md-3">
<input value="peixes" type="checkbox" /><label>Peixes</label>
</div>
<div class="col-md-3">
<input value="frango" type="checkbox" /><label>Frango</label>
</div>
<div class="col-md-3">
<input value="carne-suina" type="checkbox" /><label>Carne de Suína</label>
</div>
<div class="col-md-3">
<input value="carne-bovina" type="checkbox" /><label>Carne Bovina</label>
</div>
</div>
I used a jQuery to print the list but I would like you to print only the selected items.
<!--input type="text" id="myVal" value=""-->
<input id="printButton" type="button" value="Imprimir Lista" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/printThis/1.14.0/printThis.min.js"></script>
<script type="text/javascript">
jQuery(function ($) {
/*$(":checkbox").change(function() {
var arr = $(":checkbox:checked").map(function() { return $(this).val(); }).get();
$("#myVal").val(arr.join('/'));
});*/
$("input:button").click(function () {
$('input[type="checkbox"]').each(function() {
var $this = $(this);
if($this.is(':checked')) {
$this.attr('checked', true);
} else {
$this.removeAttr('checked');
}
});
$("#printing").printThis({
pageTitle: "Lista de Compras ",
importStyle: true
});
});
});
</script>
Hello friend welcome to the SOPT, please post the code and not the image of it.
– MSLacerda
I’m sorry, I made the change
– Grafite
Which button do you push to
imprimir
?– Jorge.M
i use the List print button according to the code below < input id="printButton" type="button" value="Print List" />
– Grafite