Jump to content

help with combobox jquery (offline work online worst)


havide

Recommended Posts

lokal_lancar.jpg

online_error.jpg

I use firebug to detect how javascript work. It same code. the java script :

<script type="text/javascript">
$(function() {
     $("#cmbNegara").change(function(){
          $("img#imgLoad").show();
          var kodejeniskayu = $(this).val();
 
          $.ajax({
             type: "POST",
             dataType: "html",
             url: "getProvinsi.php",
             data: "kodejeniskayu="+kodejeniskayu,
             success: function(msg){
                 if(msg == ''){
                         $("select#cmbProvinsi").html('<option value="">--Pilih Ukuran--</option>');
                         $("select#cmbKota").html('<option value="">--Pilih Ukuran--</option>');
                 }else{
                           $("select#cmbProvinsi").html(msg);                                                       
                 }
                 $("img#imgLoad").hide();
 
                 getAjaxAlamat();                                                        
             }
          });                    
     });
 
     $("#cmbProvinsi").change(getAjaxAlamat);
     function getAjaxAlamat(){
          $("img#imgLoadMerk").show();
          var kodeukuran = $("#cmbProvinsi").val();
 
          $.ajax({
             type: "POST",
             dataType: "html",
             url: "getKota.php",
             data: "kodeukuran="+kodeukuran,
             success: function(msg){
                 if(msg == ''){
                         $("select#cmbKota").html('<option value="">--Stok Kosong--</option>');                                                                                  
                 }else{
                           $("select#cmbKota").html(msg);                              
                 }
                 $("img#imgLoadMerk").hide();                                                        
             }
          });
     };   

	
});
</script>

getprovinsi.php

<?php require_once('Connections/karyo.php'); ?>
<?php
ini_set('display_errors',0);
//ambil parameter
$kodejeniskayu = $_POST['kodejeniskayu'];

if($kodejeniskayu == ''){
     exit;
}else{
     $sql ="SELECT kodeukuran,ukuran FROM tukuran WHERE kodejeniskayu='$kodejeniskayu'";
     $getNamaProvinsi = mysql_query($sql,$karyo) or die ('Query Gagal');
     while($data = mysql_fetch_array($getNamaProvinsi)){
          echo '<option value="'.$data['kodeukuran'].'">'.$data['ukuran'].'</option>';
     }
     exit;    
}
?>

getkota.php

<?php require_once('Connections/karyo.php'); ?>
<?php
ini_set('display_errors',0);

//ambil parameter
$kodeukuran = $_POST['kodeukuran'];
 
if($kodeukuran == ''){
     exit;
}else{
     $sql ="SELECT idstok,harga FROM tstok WHERE kodeukuran = '$kodeukuran'";
     $getNamaKota = mysql_query($sql,$karyo) or die ('Query Gagal');
     while($data = mysql_fetch_array($getNamaKota)){
          echo '<option value="'.$data['idstok'].'">'.$data['harga'].'</option>';
     }
     exit;    
}
?>

the problem at online is, the combobox at getprovinsi not showing up. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.