2015-10-13 51 views
-1

我這個Yii輸入添加到我的表格:動態Yii的輸入與jQuery

echo $form->dropDownList($model,'contact_type_id',$model->getContactParams(), array('class'=>'form-control')); 

是否有可能與jQuery動態添加此輸入?

+0

你想添加一個選擇框,動態地在jquery中? –

+0

是的。我想動態添加下拉列表 – HugeD

+0

是靜態下拉值?或者你需要從數據庫中獲取? –

回答

0

爲此使用ajax。

$('#addContact').click(function() { 

     $.ajax({ 
      url: "your url here", 
      type: "POST", 
      dataType: "HTML", 
      async: false, 
      data: {"name":value},//if you want to send any data. 
      success: function(data) { 
         //  here append the select to required div.      
      } 
     }); 
}); 

在url中,您從數據庫中獲取數據並在那裏打印。

+0

與您現有的附件,調用ajax並將選擇添加到您的頁面。 –

+0

你能舉個例子嗎?我是新來的jQuery – HugeD

+0

你想要什麼類型的例子?現場演示?/ –