i have 2 combobox , if i select value "foto" , the other combobox will show #foto_cat. when i choose "panen" the foto_cat is hidden and else. if not choose, the foto_cat is hidden too.
this is my script
<script type="text/javascript">
$(document).ready(function(){
$('#combo1').change(function(){
x=$(this).val();
if(x=='foto'){
$('#foto_cat').show();
}
else if(x=='panen'){
$('#foto_cat').hide();
}
else{
$('#foto_cat').hide();
$('#foto_cat').val('0');
}
});
});
</script>
<p class="blok">
<label for="id">Kategori Report :</label>
<?php
$options = array(
'0' => '--------',
'panen' => 'Panen',
'foto' => 'Foto',
);
echo form_dropdown('combo[combo1]',$options,'0','id="combo1"');
?>
</p>
<p class="blok" id="foto_cat" style="display:none">
<label for="id">Kategori Foto :</label>
<?php
$options = array(
'0' => '--------',
'pupuk' => 'Pemupukan',
'pelihara' => 'Pemeliharaan',
);
echo form_dropdown('combo[combo5]',$options,'0','id="combo5"');
?>
</p>
the question is . how to change combobox id=combo5 when i choose in combo1 value = "0" the combobox combo5 will select same value = 0 and hide other option, when i choose value "foto" the combobox is show and the option will show too?.
sory for my bad english.
try something like
function SetSel(val)
{
var secondCombo = document.getElementById ( "cmb" );
secondCombo.value = val.value;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.