我正在尝试在一个下拉列表中进行2个onchange事件。 onchange事件是:
onchange事件都成功,但是当我将onchange事件合并到一个下拉列表中时,它不起作用。下面是我的源代码:
JavaScript:
<script>
function show(select_item) {
if (select_item == "Hourly") {
hiddenDiv.style.visibility='visible';
hiddenDiv.style.display='block';
Form.fileURL.focus();
}
else{
hiddenDiv.style.visibility='hidden';
hiddenDiv.style.display='none';
}
}
</script>
_form.php:
$form->field($model, 'report_type[]')->dropDownList(
['Hourly' => 'Hourly', 'Daily' => 'Daily', 'Weekly' => 'Weekly', 'Monthly' => 'Monthly'],
//onchange for hide div
['onchange' => 'java_script_:show(this.options[this.selectedIndex].value)'],
//onchange for dependent dropdownlist
[
'prompt'=>'-Choose Report Type-',
'onchange'=>'
$.post( "index.php?r=report-scheduler/list&report_day="+$(this).val(), function( data ) {
$( "select#reportscheduler-report_day").html( data );
});
']);