我在div中有一个select表单元素,我想将该div的内容(select元素)附加到我的表单中。 我尝试了下面的代码,它的附加非常好,但是选择变为非活动状态,并且变更事件不再有效。 任何帮助将不胜感激谢谢。
//JAVASCRIPT CODE getting the div//
function getList(serial){
return document.getElementById('selecter').outterHtml;
}
//Div Containing the SelectElement//
<div id="selecter">
<?php
$data = Arrayhelper::map(Goods::find()->all(), 'p_code', 'name');
// without model
echo Select2::widget([
'name' => 'p_name[]',
'data' => $data,
'options' => ['placeholder' => 'Select Prroduct ...',
'class'=>'form-control',
'onchange'=>'
$.post( "index.php?r=goods/list&id='.'"+$(this).val(), function(data){
document.getElementById("eset").value = data;
});'],
'pluginOptions' => [
'allowClear' => true
],
]);?>
</div>
//End of Div//
onclick calls the getList function