这是我的数组
$m3 = array
(
'2' => '2',
'4' => '4',
'6' => '6',
'9' => '9',
'14' => '14',
'18' => '18',
'20' => '20',
'other' => 'other'
);
如何让'other'改变我在输入字段'other_interest'中的内容?
<?=$form->input('Car/m3', array('name' => "other_interest", 'style' => "display:none", 'class' => 'inputText', 'label' => false));?>
当我选择其他
时,jQuery显示输入字段 <script>
jQuery(document).ready(function() {
jQuery("#CarM3").change(function() {
if (jQuery(this).val() === 'other'){
jQuery('input[name=other_interest]').show();
} else {
jQuery('input[name=other_interest]').hide();
}
});
});
</script>
答案 0 :(得分:0)
我从你的问题中理解的是,你想要&#34;其他&#34;将显示在输入字段中:&#34; other_interest&#34;。
<script>
jQuery(document).ready(function() {
jQuery("#CarM3").change(function() {
if (jQuery(this).val() === 'other'){
jQuery('input[name=other_interest]').show();
//in the above line, you are just displaying the inputfield
jQuery('input[name=other_interest]').val("other") //adding this line should do the trick for you!
} else {
jQuery('input[name=other_interest]').hide();
}
});
});