Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Script Ajax-->
- <script type="text/javascript">
- $(function(){
- $.ajaxSetup({
- type:"POST",
- url: "<?php echo base_url('index.php/select/ambil_data') ?>",
- cache: false,
- });
- $("#j_kI").change(function(){
- var value=$(this).val();
- if(value>0){
- $.ajax({
- data:{modul:'kamar_ikhwan',id:value},
- success: function(respond){
- $("#kamar").html(respond);
- }
- })
- }
- });
- $("#j_kA").change(function(){
- var value=$(this).val();
- if(value>0){
- $.ajax({
- data:{modul:'kamar_akhwat',id:'value'},
- success: function(respond){
- $("#kamar_akhwat").html(respond);
- }
- })
- }
- });
- })
- </script>
- <!--END script ajax-->
- <!--COntrollel-->
- function ambil_data(){
- $modul=$this->input->post('modul');
- $id=$this->input->post('id');
- //kamar
- if($modul=="kamar"){
- echo $this->model_select->kamar_ikhwan();
- }
- elseif($modul=="kamar_akhwat"){
- echo $this->model_select->kamar_akhwat();
- }
- }
- <!-- END COntrollel-->
- <!--HTML-->
- <div class="form-group">
- <label class="control-label col-md-3 col-sm-3 col-xs-12">Jenis Kelamin
- </label>
- <div class="col-md-6 col-sm-6 col-xs-12">
- Laki-laki: <input type="radio" class="flat" name="j_k" id='j_kI' value="<?php echo $j_k; ?>" checked="" />
- Perempuan: <input type="radio" class="flat" name="j_k" id="j_kA" value="<?php echo $j_k; ?>" />
- </div>
- </div>
- <div class="form-group">
- <label class="control-label col-md-3 col-sm-3 col-xs-12" for="varchar">Kamar <?php echo form_error('kamar') ?></label>
- <div class="col-md-6 col-sm-6 col-xs-12">
- <select class='form-control' id='kamar' name="kamar">
- <option value='0'>--pilih--</option>
- </select>
- </div>
- </div>
- <!--END HTML-->
- <!--Model-->
- function kamar_akhwat(){
- $kamar="<option value='0'>--pilih--</pilih>";
- $this->db->order_by('kamar','ASC');
- $jur= $this->db->get('kamar_akhwat');
- foreach ($jur->result_array() as $data ){
- $jur1.= "<option value='$data[id]'>$data[kamar]</option>";
- }
- return $jur1;
- }
- function kamar_ikhwan(){
- $kamar="<option value='0'>--pilih--</pilih>";
- $this->db->order_by('kamar','ASC');
- $jur= $this->db->where('kamar');
- foreach ($jur->result_array() as $data ){
- $jur1.= "<option value='$data[id]'>$data[kamar]</option>";
- }
- return $jur1;
- }
- <!--END model-->
Add Comment
Please, Sign In to add comment