2014-01-27 2 views
0

자동 완성 검색 필드에서 필수 값을 선택한 후 자동 완성 드롭 다운 onchange 코드를 작업하고 있습니다. 문제는 내 autofill 값을 선택한 후 작동하지 않습니다 있지만 Jquery 스크립트를 실행하고 ID를 완벽하게 작동, 내가 무엇을 놓치고 있는지 모르겠다. 여기에 약간의 코드와 그림이 있습니다. 메모 나는 프로그램의 유형을 실행하는 여러 jquery 스크립트가 있습니다.선택 후 자동 완성 드롭 다운

C:\xampp\htdocs\portal-gep-2\application\modules\admin\controllers\AjaxController.php(366): Model_SicCode->getsiccode('50390' 

요청 매개 변수 :

array (
    'controller' => 'ajax', 
    'action' => 'autofill', 
    'sicid' => '50390', 
    'lang' => 'en', 
    'module' => 'admin', 
) 

는 ID가 내 데이터베이스에 존재하지만 내 드롭 다운 그냥 변경하지 마십시오 여기에 내가
Message: Could not find row 50390

스택 추적 얻을 오류 메시지입니다. 이 문제를 어떻게 해결할 수 있습니까?

contoller 

    public function autofillAction() 
    { 
     //get the id send via a get - the sic id 
     $division= $this->getRequest()->getParam('sicid'); 

     //get majorgroup name, group name and sic description 
     //fill dropdowns with relevant values - new form with drop downs 
     //selecting the required values same as autocomplete (don't know) 
     $mdlSic = new Model_SicCode(); 
     $results = $mdlSic->getsiccode($division); 
     foreach($results as $result) 
     { 
      $Division = $result->div_code; 

      $mdlDivision = new Model_Division(); 
      $result = $mdlDivision->getSicViaDiv($division); 
      $name = $result->div_desc; 
      $id = $result->div_code; 


      $mgrp_desc->addMultiOption($id, $name); 
     } 
     $mgrp_desc->setOrder(4); 

     $this->_helper->viewRenderer->setNoRender(false); 
     $this->_helper->layout->disableLayout(); 

     $ajaxContext = $this->_helper->getHelper('AjaxContext'); 
     $ajaxContext->addActionContext('newfield', 'html')->initContext(); 

     $id = $this->_getParam('id', null); 

     $this->view->field = $div_desc->__toString(); 
    } 


jquery 

    function ajaxautofill(id) { 
      $.ajax({ 
      type: 'POST', 
      datatype: 'JSON', 
      url: '<?php echo $this->baseURL()?>/admin/ajax/autofill/sicid/' + id, 


         //data: 'division':$('#div_desc').val(), 
         //dataType: 'JSON', 
         //async: true, 
         success: function(data) 
         { 
          //fill drop downs 

          $('#t2').append(data); 
         } 
      }); 
     } 

첫째, 당신은구축했습니다

public function getSicViaDiv($siccode) 
     { 
      $select = $this->select(); 
      $select->where('div_code = ?', $siccode); 

      return $this->fetchAll($select); 
     } 

enter image description here

답변

0

가져 오기 siccode

public function getSICviaDiv($d_id) 
      { 
       $select = $this->select()->where('div_code = ?', $d_id);  


        $results = $this->fetchAll($select); 
       if (count($results)) 
        return $results; 
       else 
        return 'nothing'; 

}

GetsicViaDiv개체를 두 번. 둘째, 내가 대답을 건의 할 것입니다 것은 여기에 다음 RowSet 개체가 fetchRow에서 반환하는 경우

$row = $this->fetchRow($select);  
if (!$row) 
{ 
    throw new Exception("Could not find row $id"); 
} 

당신은 예외를 발생하고, false입니다. 나는 오늘 랩톱 컴퓨터를 가지고있을 때 약간의 코드를 만들어 낼 것이다.

+0

죄송합니다. 코드를 수정했습니다. –

관련 문제