开发者

Javascript not loading for php generated form

开发者 https://www.devze.com 2023-01-05 23:08 出处:网络
I am using phpBMS, and have made a form, similar to the sample provided. Using the provided input fields, I have made a basic dropdown list containing two items, and a checkbox.

I am using phpBMS, and have made a form, similar to the sample provided.

Using the provided input fields, I have made a basic dropdown list containing two items, and a checkbox.

I want the checkbox to be selected automatically when one of the options from the dropdown box is selected.

Jens F, provided me with a solution to how I should do this in javascript here.

However, for some reason I can not get the javascript to execute.

I have the javascript in a file called checkpaid.js, which is included in my form. Using firebug I can see that the javscript file is fetched, and it appears in the list of scripts, but it is absolutely never executed at all.

How would I start to figure out why it is not executing, when it is clearly being included in the page?

Here is an example of the provided javascript for an existing form, which takes an action if a radio button is clicked.

Here is my current form and 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");


IS the page loading as you've missed a ; after

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号