[eluser]haily_php[/eluser]
I have done well to show data from second select box through first select-box; but i have one problem. First, if i chosen the first value, ( in second select-box) program would have not run; it would run from other values. Then, I chosen first value again, it run normally
How will I do to get the first value and to show data in second select-box automatically when I'll run program first
-- First Select-box ---
Quote:<select name="sub2_mainmenu" id="sub2_mainmenu">
<?php
foreach($info as $item){
?>
<option value="<?php echo $item['idmainmenu'];?>"><?php echo $item['tieude'];?></option>
<?php } ?>
</select>
--Javascript--
Quote:[removed]
$('#sub2_mainmenu').change(function() {
var form_data = {
sub2_mainmenu: $("#sub2_mainmenu").val(),
};
$.ajax({
url: "<?=site_url("index.php/menu/menu2/process/");?>", // controller: menu2; action: process
type: 'POST',
data: form_data,
success: function(msg) {
$('#submenu').html(msg);
}
});
});
[removed]
-- Second Select-box --
Quote:<select name="sub2_mainmenu" id="sub2_mainmenu">
<?php
if($info){
foreach($info as $item){
?>
<option value="<?php echo $item['idsubmenu'];?>"><?php echo $item['tieude'];?></option>
<?php }}else{
echo "<option value='A'>Updating data...</option>";
}
?>
</select>