Javascript не загружается для php сгенерированной формы - PullRequest
2 голосов
/ 02 июля 2010

Я использую phpBMS и создал форму, похожую на предоставленный образец .

Используя предоставленные поля ввода, я создал основной выпадающий список, содержащий два элемента, ифлажок.

Я хочу, чтобы флажок устанавливался автоматически при выборе одного из параметров в раскрывающемся списке.

Йенс 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");

1 Ответ

0 голосов
/ 13 ноября 2011

- это загрузка страницы, когда вы пропустили;после

<?php $theform->startForm($pageTitle)?> 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...