未加载php生成表单的Javascript

未加载php生成表单的Javascript,php,javascript,ajax,forms,phpbms,Php,Javascript,Ajax,Forms,Phpbms,我正在使用phpBMS,并制作了一个表单,类似于 使用提供的输入字段,我创建了一个包含两个项目和一个复选框的基本下拉列表 我希望在选择下拉框中的一个选项时自动选中该复选框 Jens F为我提供了一个解决方案,说明我应该如何用javascript实现这一点 但是,由于某些原因,我无法执行javascript 我将javascript保存在一个名为checkpaid.js的文件中,该文件包含在我的表单中。使用firebug,我可以看到javscript文件已被提取,并出现在脚本列表中,但它绝对不会执

我正在使用phpBMS,并制作了一个表单,类似于

使用提供的输入字段,我创建了一个包含两个项目和一个复选框的基本下拉列表

我希望在选择下拉框中的一个选项时自动选中该复选框

Jens F为我提供了一个解决方案,说明我应该如何用javascript实现这一点

但是,由于某些原因,我无法执行javascript

我将javascript保存在一个名为checkpaid.js的文件中,该文件包含在我的表单中。使用firebug,我可以看到javscript文件已被提取,并出现在脚本列表中,但它绝对不会执行

当它明显包含在页面中时,我如何开始找出它为什么不执行

是为现有表单提供的javascript的一个示例,如果单击单选按钮,它将执行一个操作

以下是我当前的表单和javascript:

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

    include("../../include/session.php");
    include("include/tables.php");
    include("include/fields.php");

    include("include/sales.php");

    if(!isset($_GET["backurl"]))
        $backurl = NULL;
    else{
        $backurl = $_GET["backurl"];
        if(isset($_GET["refid"]))
            $backurl .= "?refid=".$_GET["refid"];
    }

    $thetable = new sales($db, "tbld:490cf2d1-1c72-7b99-461d-b1b8e68553c4");
    $therecord = $thetable->processAddEditPage();

    if(isset($therecord["phpbmsStatus"]))
        $statusmessage = $therecord["phpbmsStatus"];

    $pageTitle = "Sales";

    $phpbms->cssIncludes[] = "pages/menus.css";
    $phpbms->jsIncludes[] = "modules/base/javascript/menu.js";
    $phpbms->jsIncludes[] = "modules/micro hospitality/javascript/checkpaid.js";

    $phpbms->onload[] = "initializePage()";

        $theform = new phpbmsForm();

        $theinput = new inputSmartSearch($db, "chooseguests", "Choose Guests",NULL, "Choose Guest", TRUE, NULL, NULL, TRUE, $required=true);
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $theinput = new inputSmartSearch($db, "chooseproducts", "Choose Product",NULL, "Choose Product", TRUE, NULL, NULL, TRUE, $required=true);
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $theinput = new inputField("quantity",$therecord["quantity"],"Quantity",true, NULL, 1);
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $theinput = new inputBasicList("type",$therecord["paymenttype"],array("Cash"=>"cash","Credit"=>"credit"), "Payment Type");
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $theinput = new inputCheckbox("paid", $therecord["paid"], "Paid");
        $theform->addField($theinput);

        $theinput = new inputField("receiptno",$therecord["receiptno"],"Receipt No",true, NULL, 10);
        $theinput->setAttribute("class","important");
        $theform->addField($theinput);

        $thetable->getCustomFieldInfo();
        $theform->prepCustomFields($db, $thetable->customFieldsQueryResult, $therecord);
        $theform->jsMerge();

    include("header.php");

?><div class="bodyline">

    <?php $theform->startForm($pageTitle)?>

    <div id="leftSideDiv">
        <fieldset>
            <legend><label for="S">Sales</label></legend>

            <p class="big"><?php $theform->showField("chooseguests"); ?></p>
            <p class="big"><?php $theform->showField("chooseproducts"); ?></p>
            <p class="big"><?php $theform->showField("quantity"); ?></p>
            <p class="big"><?php $theform->showField("type"); ?></p>
            <p class="big"><?php $theform->showField("paid"); ?></p>
            <p class="big"><?php $theform->showField("receiptno"); ?></p>


        </fieldset>

    </div>
    <?php
        $theform->showGeneralInfo($phpbms,$therecord);
        $theform->endForm();
    ?>
</div>
<?php include("footer.php");?>


------------------
checkpaid.js: 

window.addEvent('domready', function(){
  $('type').addEvent('change',function(){
    if($(this).get('value') == 'credit') {
      $('paid').set('checked','checked');
    } else {
      $('paid').removeProperty('checked');
    }
  });
});
alert("loaded");

销售额

------------------ checkpaid.js: addEvent('domready',function(){ $('type').addEvent('change',function(){ if($(this).get('value')=='credit'){ $('paid').set('checked','checked'); }否则{ $('paid').removeProperty('checked'); } }); }); 警报(“已加载”);
是页面加载,因为您错过了一个页面;之后

<?php $theform->startForm($pageTitle)?> 

是页面加载,因为您错过了一个页面;之后

<?php $theform->startForm($pageTitle)?> 


您使用的是什么JavaScript库?也就是说,是什么提供了domready事件钩子?phpBMS使用mootools,这就是它要使用的。它实际上在phpbms之外工作。请确保下拉列表的ID实际上是“type”,您可以放置一个警报语句或“console.log”(“executed”)在更改事件中查看代码是否正在执行。如果没有,请发布页面的url,以便我可以进一步研究。我无法为您提供访问我的页面的权限。我会的,但我支持NAT,无法更改它。ID的类型与您在我的表单中看到的完全相同,并在输出HTML中确认。我同时放了一个alert和console.log(“已执行”),而且它似乎根本没有执行…但我不明白为什么?检查控制台是否有错误。另外,验证mootools库是否确实正在加载。您使用的JavaScript库是什么?例如,是什么提供了domready事件挂钩?phpBMS使用mootools,这就是它要使用的。它确实工作在phpbms之外。请确保下拉列表的ID实际上是“type”,您可以在更改事件中放置一条警报语句或“console.log”(“executed”),以查看该代码段是否确实在执行。如果没有-发布一个页面的url,这样我可以进一步调查。我不能提供你访问我的页面的权限。我会的,但我支持NAT,没有权限更改它。正如您在我的表单中看到的那样,ID是明确的类型,并且在输出HTML中得到确认。我同时放了一个alert和console.log(“executed”),它显然根本没有执行……但我不明白为什么?检查控制台是否有错误。此外,请验证mootools库是否确实正在加载。