[英]How to apply Onclick on my dropdown [ codeigniter ]
I have a dropdown list then submit form when you click select values from dropdown 我有一个下拉列表,然后单击从下拉列表中选择值时提交表单
using this code 使用此代码
onchange="this.form.submit()"
But I don't know how to put this on my dropdown check my code below, 但是我不知道如何将其放在下拉菜单中,检查下面的代码,
<?php foreach($options as $key_option=>$val_option):?>
<div class="col-lg-3">
<label class="control-label">
<?php echo $required_notice.$val_option['option']?>
<?php if(!empty($options_lang[$key][$key_option]->hint)):?>
<i class="icon-question-sign hint" data-hint="
<?php echo $options_lang[$key][$key_option]->hint;?>">
</i>
<?php endif;?>
</label>
<?php
if(isset($options_lang[$key][$key_option])){
$drop_options = array_combine(explode(',',check_combine_set(isset($options_lang[$key])?$options_lang[$key][$key_option]->values:'', $val_option['values'], '')),explode(',',check_combine_set($val_option['values'], isset($options_lang[$key])?$options_lang[$key][$key_option]->values:'', '')));
} else {
$drop_options = array();
}
// If you don't want translation to website langauge uncomment this 1 line below:
// $drop_options = array_combine(explode(',', $options_lang[$key][$key_option]->values), explode(',', $options_lang[$key][$key_option]->values));
$drop_selected = set_value('option'.$val_option['id'].'_'.$key, isset($estate['option'.$val_option['id'].'_'.$key])?$estate['option'.$val_option['id'].'_'.$key]:'');
echo form_dropdown ('option'.$val_option['id'].'_'.$key, $drop_options, $drop_selected, 'class="form-control" id="inputOption_'.$key.'_'.$val_option['id'].'" placeholder="'.$val_option['option'].'" '.$required_text)
?>
</div>undefined</div>
<?php endforeach;?>
Output 输出量
Thankyou 谢谢
NOTE: My dropdown is inside a foreach 注意:我的下拉列表位于foreach内部
You should put your onchange prop into your form_dropdown
function so your select option will have the event you want, submit while option changed. 您应该将onchange道具放入
form_dropdown
函数中,以便您的选择选项具有您想要的事件,并在选项更改时提交。
<div class="col-lg-3">
<label class="control-label">
<?php echo $required_notice.$val_option['option']?>
<?php if(!empty($options_lang[$key][$key_option]->hint)):?>
<i class="icon-question-sign hint" data-hint="
<?php echo $options_lang[$key][$key_option]->hint;?>">
</i>
<?php endif;?>
</label>
<?php
if(isset($options_lang[$key][$key_option]))
{
$drop_options = array_combine(explode(',',check_combine_set(isset($options_lang[$key])?$options_lang[$key][$key_option]->values:'', $val_option['values'], '')),explode(',',check_combine_set($val_option['values'], isset($options_lang[$key])?$options_lang[$key][$key_option]->values:'', '')));
}
else
{
$drop_options = array();
}
// If you don't want translation to website langauge uncomment this 1 line below:
// $drop_options = array_combine(explode(',', $options_lang[$key][$key_option]->values), explode(',', $options_lang[$key][$key_option]->values));
$drop_selected = set_value('option'.$val_option['id'].'_'.$key, isset($estate['option'.$val_option['id'].'_'.$key])?$estate['option'.$val_option['id'].'_'.$key]:'');
echo form_dropdown ('option'.$val_option['id'].'_'.$key, $drop_options, $drop_selected, 'onchange="this.form.submit()" class="form-control" id="inputOption_'.$key.'_'.$val_option['id'].'" placeholder="'.$val_option['option'].'" '.$required_text)
?>
</div>undefined</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.