javascript - easyui 添加整列

标签 javascript php jquery

我目前正在使用easyui datagrid,我只需要在数据网格中添加整个列并将它们放入文本框或其他内容中 add debit and credit

enter image description here

我只需要添加它们然后显示并比较 也可以使用php来做吗? 提前致谢 :) 我尝试在他们的论坛中询问,但似乎他们不再接受任何成员(member)。 我也尝试过使用这个

$.post('show_details.php', {v: row.checkvou});
        $('#sd').form('load',row);

我希望能够获得“checkvou”的值,然后创建一个新函数来添加和比较它,但没有像你在图片中看到的那样幸运,它显示“ undefined index ” 至于文本框中的“1231231”,它仅使用javascipt显示

编辑:或者至少帮我将该文本框的值获取到 php 变量,这是文本框的代码:

<input name="checkvou" id="checkv" class="easyui-textbox"  ></input>

这也会很有帮助:D

最佳答案

哇,我实际上忘记回到这里来发布我是如何解决这个问题的,抱歉......无论如何......

我的解决方案是创建另一个文件然后将其包含

include "dc_compute.php";

原因是我发现你无法将 javascript 变量传递给 php (这就是为什么 $('#checkv').textbox('getValue') 对我不起作用(感谢 Mawia HL 的建议)) 然后在该文件内有一个函数,它从数据库获取数据并进行计算,然后返回结果,为了让事情清楚,这里是代码:

include "dc_compute.php";
$data = compute($_REQUEST['checkvou']); // $_REQUEST['checkvou'] is where the value of the textbox '#checkv' came from

dc_compute.php:

function compute($itemid){

    include 'conn.php';
    $debcred = array();
    //echo $itemid;
    $query1 = "SELECT * FROM editlist WHERE checkvou = '".$itemid."'";
    $query1_run = mysql_query($query1);
    //echo $query1_run;
    $deb = 0;
    $cred = 0;
    $qty = 0;
    while ($num = mysql_fetch_assoc($query1_run)) {
        // this is the part where it does the adding thing
        $deb += $num['debit'];
        $cred += $num['credit'];
    }

    array_push($debcred, $deb,$cred);
    return $debcred;
}

最后它只是一个简单的 if 条件来知道它们是否平衡:D 最后就是它的样子:

include "dc_compute.php";
$data = compute($_REQUEST['checkvou']);

    if ($data[0] != $data[1]){

        ?>
        <h1 style="font-size: 20px; color:#8A0707">UNBALANCED CHEQUE!!</h1>

        <?php 
    }

this is what the output look like

我知道,我知道这不是最好的答案,但这对我有用,如果你们有任何建议,我会洗耳恭听:D

关于javascript - easyui 添加整列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38347355/

相关文章:

javascript - Vue-Select 事件触发器,无需 Node.js

php - Bisna Doctrine 2.1 和 2.2 从未导入注释 "@Table"

javascript - jquery模拟select中所有选项的点击事件,从多个select选项中获取数据

php - .htaccess 重写传递 2 个参数的 URL

php - Twig 缓存究竟是如何工作的?

jquery - 在网站上导航上一篇/下一篇文章的最佳方式

jquery - 有没有一种简单的方法可以将 jQuery 与 Simile Timeplots 一起使用?

javascript - 如果 [] 是 [] 并且 Array.prototype 是 [] 为什么不 ([] == Array.prototype)

JavaScript 编辑 : how to disable a css class and add other when current?

javascript - 检查任何 if 语句中是否使用了 Javascript 变量