mardi 7 mars 2017

Show content depending on checked checkboxes in laravel dom-pdf

Hi could anyone help me with this? It should be a simple solution but it seems i cant get it figured out. I can get it to work in standart laravel (i use 5.3.28) view, but not in dompdf pdf file.

what i have is a checkboxes form:

<form method="get" action="pdfview">
    <input name="objid" type="hidden" value="">
    <b>Basic info - 3.50 EUR</b><br/>
    <input type="checkbox" name="opt1" value="3.00">opt1 - 3 EUR<br/>
    <input type="checkbox" name="opt2" value="1.50">opt2 - 1.50 EUR<br/>
    <input type="checkbox" name="opt3" value="3.60">opt3 - 3.60 EUR<br/>
    <input type="checkbox" name="opt4" value="2.50">opt4 - 2.50 EUR<br/>
    <input type="checkbox" name="opt5" value="2.80">opt5 - 2.80 EUR<br/>
    <input type="checkbox" name="opt6" value="2.50">opt6 - 2.50 EUR<br/>
    <input type="checkbox" name="opt7" value="3">opt7 - 3 EUR<br/>
    <input type="checkbox" name="opt8" value="2.50">opt8 - 2.50 EUR<br/>
    <input type="checkbox" name="opt9" value="2.50">opt9 - 2.50 EUR<br/>
    <input type="checkbox" name="opt10" value="3.50">opt10 - 3.50 EUR<br/>
    <input type="checkbox" name="opt11" value="3.50">opt11 - 3.50 EUR<br/>
    <input type="checkbox" name="opt12" value="2.50">opt12 - 2.50 EUR<br/>
    <input type="checkbox" name="opt13" value="3">opt13 - 3 EUR<br/>
    <h2>SUM: <span name="total" class="total">3.50</span> EUR</h2>
    <BR>
    <input type="submit" id="adress_submit" value="search" class="btn btn-primary">
</form>

</div>
<script>
    $(function () {
        $('input').click(function () {

            var total = 3.50;
            $('input:checked').each(function (index, item) {
                total += parseFloat(item.value);
            });
            $('.total').text(total);
        });
    });
</script>

and then in controller i use code like this:

if (Input::get('opt1') === '3.00') {
    $opt1html = "opt1 is checked <BR>";
} else {
    $opt1html = '';
}

this works in a laravel view with this code:

@if(isset($opt1html)){!! $opt1html !!} @endif

but not in dompdf pdf file.

@if(isset($opt1html))opt1 is checked @endif

Does anyone have a solution for this? Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire