Php ve jquery nasıl bağlanacağını

0 Cevap php

Is it possible to use php to compute something and use jquery to fetch the computed value and display it back to the webpage without the need to submit the form. I'm really having trouble using client-side to compute something that is using arrays. So I'm thinking of letting php do the computation.

                    <input type="hidden" name=ids[] value="<?php $id; ?>">
                    <input type="hidden" name=qoh[] value="<?php $qtyhand; ?>">

                    <input type="hidden" name=dprice[] value="<?php $dsprice; ?>">
                    <input type="hidden" name=sprice[] value="<?php $ssprice; ?>">

                    <td>$qtyhand</td>";
                    <td><input type="text" name=qbuys[]  value="<?php echo $ssprice; ?>"></td>
                    <td><?php $ssprice; ?></td>";
                    <td><input type="text" name=disc[]  value=""></td>


                    <td><input type="text" name=subtot[]  value=""></td>

Ve burada hesaplamak için kullanılacak olması gerekiyordu php dosyasıdır.

<?php
    $ctbill=0;
    foreach ($_GET['ids'] as $k => $v) {
        $id = (int)$v;
        $qtyhnd = (int)$_GET['qoh'][$k];
        $qtytbuy = (int)$_GET['qbuys'][$k];
        $left = $qtyhnd - $qtytbuy;



        $sellprice=(double)$_GET['sprice'][$k];
        $dealerprice=(double)$_GET['dprice'][$k];

        $finalvalue=.01;
        $dis=(double)$_GET['disc'][$k];




        $stotal=(double)$qtytbuy * $sellprice;
        $cdizval=(double)$stotal * $dis * $finalvalue;
        $cdstotal=$stotal-$cdizval;

        $ctbill=(double)$ctbill + $cdstotal; 






        $dizval=$dis * $finalvalue;
        $preprof=(($sellprice * $qtytbuy)-($dealerprice*$qtytbuy)) * $dizval;
        $profit=(($sellprice * $qtytbuy)-($dealerprice*$qtytbuy)) - $preprof;

    ?>

Bana bunu yapmak için nasıl bir fikir verebilir.

0 Cevap