2011-10-05 2 views
0

데이터베이스에서 채워지는 드롭 다운 목록이 있습니다. 그것은 잘 작동하지만보기 파일의 form_dropdown에서 Jquery를 사용하여 드롭 다운의 유효성 검사에 class = "required"를 추가하려고합니다. 나는 그것을 작동 시키려고 노력했지만 그것이 나오면 작동하지 않을 것이다. 당신이 친절하게 제게 클래스 = "필수"를 넣으려면 정확히 어디에서 도와 주시겠습니까 - jquery 검증 작업을 만드시겠습니까?add_class = "required"(jquery 유효성 검사)에서 form_dropdown?

덕분에 사전에

나는 내 컨트롤러 내 모델 -

function dropdown_batchlist() { 
    $this->db->select('batchname, batchid'); 
    $records=$this->db->get('batch'); 

     $data=array(); 

    // add it here as the first item in the array, 
    // assuming you don't have a $row->batchid of 0 in your results. 
    $data[0] = 'SELECT'; 

    foreach ($records->result() as $row) 
    { 
    $data[$row->batchid] = $row->batchname; 
    } 

return ($data); 
} 

에서

// To get the batch name 
$this->load->model('dropdown_batchlist'); 
$data['dropdown_batchlist']= $this->dropdown_batchlist->dropdown_batchlist(); 

이이 있고이 내보기 파일

<?php echo form_dropdown('batchid', $dropdown_batchlist,'', 'class="required"'); ?> 

Solv에 문제가있다. ed

문제를 파악했습니다. 보기 파일은 괜찮 았어, 내가해야 할 일은 $ data [0] = 'SELECT'; $ 데이터 [ ''] = 'SELECT';

감사

연관 배열을 사용하여 속성을 설정

답변

0

시도 :

$attributes = array(
    'name' => 'batchid', 
    'class' => 'required', 
    'options' => $dropdown_batchlist 
); 
echo form_dropdown($attributes); 
관련 문제