2010-07-01 8 views
2

저는 phpBMS를 사용 중이며 sample provided과 비슷한 양식을 작성했습니다.자바 스크립트가 로딩되지 않았습니다.

제공된 입력란을 사용하여 두 개의 항목과 체크 박스가 포함 된 기본 드롭 다운 목록을 만들었습니다.

드롭 다운 상자의 옵션 중 하나를 선택하면 확인란이 자동으로 선택되기를 원합니다.

Jens F는 javascript here에서 어떻게해야하는지에 대한 해결책을 알려주었습니다.

그러나 어떤 이유로 나는 자바 스크립트를 실행할 수 없습니다.

내 양식에 포함 된 checkpaid.js라는 파일에 javascript가 있습니다. 방화 광을 사용하면 javscript 파일을 가져 와서 스크립트 목록에 표시되지만 절대 실행되지는 않습니다.

분명히 페이지에 포함될 때 어떻게 실행되지 않는지 알아 내기 시작할 수 있습니까?

Here은 라디오 버튼을 클릭하면 작업을 수행하는 기존 양식에 제공된 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"); 
+0

어떤 자바 스크립트 라이브러리를 사용하고 있습니까? 나는. domready 이벤트 후크를 제공하는 것은 무엇입니까? –

+0

phpBMS는 mootools를 사용하는데, 이것은 mootools를 사용하기위한 것입니다. 그것은 사실 phpbms 잘 작동하지 않습니다. – Jacob

+0

드롭 다운의 ID가 실제로 "유형"인지 확인하고 변경 이벤트 내에 경고문 또는 "console.log ("executed ")를 넣어 해당 코드가 실제로 실행되고 있는지 확인할 수 있습니다. 그렇지 않습니다 - 페이지를 추가 할 수 있도록 URL을 게시하십시오 – Marko

답변

0

당신이보고 싶었어요으로 페이지 로딩입니다 : 여기

내 현재의 형태와 자바 스크립트입니다 이후

<?php $theform->startForm($pageTitle)?> 
관련 문제