codeigniter - DROPDOWN ID not being passed in CONTROLLER using ONCHANGE event AJAX -



codeigniter - DROPDOWN ID not being passed in CONTROLLER using ONCHANGE event AJAX -

my scenario this. have 2 dropdown options: building , floor. want is, when change/click value of dropdown "building", fills how many floor is. example, dropdown "building" has 2 options, allow say, building1 has 10 floors , building2 has 5 floors. when select, building1, give 10 options in dropdown "floor". , when alter building2, fill 1 time again dropdown "floor" 5 options representing no.of floors building.

so here codes: view:

<div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button> <h4 class="modal-title" id="h3">add new room</h4> </div> <div class="modal-body"> <form role="form"> <div class="form-group"> <label>building</label> <select class="form-control" name="rt" id="bldg" onchange="activate_floor();"> <option>select bldg. no</option> <?php if ($bldg_list) { foreach ($bldg_list $row) { echo "<option value=\"" . $row -> buid . "\">" . $row -> budesc . "</option>"; } } ?> </select> <label>floor</label> <select class="form-control" name="flr" id="flr"> <option>select floor. no</option> <?php if ($flr_list) { $str = 1; foreach ($flr_list $row) { while($str <= $row -> flr ){ echo "<option value=\"" . $str . "\">" . $str . "</option>"; $str++; } } } ?> </select> <label>room</label> <input class="form-control" placeholder="enter room no." required="required" id="rno" name="rno" /> <label>room type</label> <select class="form-control" name="rt" id="rt"> <option>select room type</option> <?php if ($roomtype_list) { foreach ($roomtype_list $row) { echo "<option value=\"" . $row -> rtcode . "\">" . $row -> rtdesc . "</option>"; } } ?> </select> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal"> close </button> <button type="submit" class="btn btn-primary"> save </button> </div> </div> </form> </div> </div> </div> </div> <!--end modal window -->

as can see, assigned function activate_floor() on event onchange dropdown building.

and here ajax part positioned @ footer.

<script> $(document).ready(function() { $('select#flr').attr('disabled',true); }); function activate_floor(){ var bldg_id = $('select#bldg').val(); $.ajax({ type: 'post', url: '<?php echo base_url('csettings/display_room/' )?>', data: 'buid='+bldg_id, success: function() { $('select#flr').attr('disabled',false); console.log(response); } }); } </script>

this controller:

public function display_room(){ $buid = $this -> security -> xss_clean($this -> input -> post('buid')); $data['room_list'] = $this -> msettings -> get_room(); $data['roomtype_list'] = $this -> msettings -> get_roomtype(); $data['bldg_list'] = $this -> msettings -> get_bldg(); $data['flr_list'] = $this -> msettings -> get_flr($buid); $this -> display_view('vroom',$data); }

when debug using chromes developer tool, found out id of dropdown "building" correctly beingness passed in url seen below.

but issue is, value not beingness retrieved in controller.

thanks lot reply.please take @ screenshot take in console logs. noticed, request query string dont add together id of dropdown although response gives status 200.

ajax codeigniter

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -