jeudi 9 août 2018

Want to send two variable values to another page for tcpdf output by click on button without submittion or ajax.

I used two button in a form. One submit data to save and another print button so thats why i didnt use 'action' because it will send data to page inside action on clicking save also. I cannot use ajax because i dont want it back to same page on success and i dont know to to stop backing it from it and what to write in success to stop it their inside pdf view.

here is the button code

<div class="col-lg-2 pull-right">
   <input type="submit" name="save" value="Save" class="btn btn-default btn-block btn-primary" />
   <button id="print" class="btn btn-block btn-default btn-info" onclick="printVouch();">
   <i class="fa fa-print"></i> Print</button>
</div>

the function code is :

function printVouch() {

            var vNo = document.getElementById("V_No").value;
            var tableName = 'vouchers';
            var type = 'CP';
            var heading = 'Cash Payment Voucher';

            if (vNo !== "") {
                var url = ("./print_voucher.php?q=" + vNo +    "&n="+tableName + "&t=" + type + "&h=" + heading);

                window.location.href = (url);
 //                    var win = window.open = (url, '_blank');
//         win.focus();
                alert("voucher selected exsist!");

            }
        }

i know the solution is that when click on button the url change and it take some data to that page and i know it can be done with the code inside function without alert("voucher selected exsist) but i dont know why and what bug it have that it shows exception. in short anything i add or delete from above code of function, it stop working! with such code its working in firefox now but inside crome its not working!

Aucun commentaire:

Enregistrer un commentaire