public static function printSelectFormDatabase() { $prop = LokasiIndoModel::getAllPropinsi(); //pr($prop); ?> <script> function checkOngkir() { var kota = $('#select_kota').val(); if(kota != ''){ /*if(kota == 'Jakarta'){ kota = 'Tangerang'; }*/ $('#select_kota').attr('disabled', true); $('#jnecity').html(kota); $.post('<?php echo _SPPATH; ?> ' + 'JNEUtil/getOngkir', {city: kota}, function (data) { $('#select_kota').attr('disabled', false); var obj = JSON.parse(data); if (obj['status']['code'] == 0) { var arr = obj['price']; //$('#jne_div').show(); //console.log(arr); var regular = arr[0]; var yes = null; //putarin dulu arr nya for(var x=0;x<arr.length;x++){ if(arr[x].service_code == "reg"){ regular = arr[x]; } if(arr[x].service_code == "yes"){ yes = arr[x]; } } /*console.log('in'); console.log(yes); console.log('in2');*/ //kalau punya yes if(yes!==null){ $('#jneprice_yes_hidden_exist').val('1'); $('#jneprice_yes_hidden').val(yes['value']); $('#setModeShip_yes').show(); //console.log('in2a'); }else{ $('#jneprice_yes_hidden_exist').val('0'); $('#setModeShip_yes').hide(); // console.log('in2b'); } $('#radio_reg').prop( "checked", true ); $('#jneprice_reg_hidden').val(regular['value']); $('#jneprice').text(NilaiRupiah(regular['value'])); $('#jneprice_hidden').val(regular['value']); //alert(arr[1]['value']); //$('#jne_price').text(NilaiRupiah(arr[1]['value'])); $('#jne_price_hidden').text(regular['value']); updateCost(); $('#jne_sp').text('Shipping Cost Updated!!').fadeIn().delay(3000).fadeOut(); } else { //$('#jne_price').text('Price Not Found'); $('#jneprice').html('<b>Price Not Found, Please Select Another City Or <a target="blank" href="<?php echo _SPPATH; ?> contact">Contact Us</a></b>'); alert('Price Not Found, Please Select Another City Or Contact Us'); $('#jne_sp').text('Price Not Found').fadeIn().delay(3000).fadeOut(); } }); } //if kota not empty } function getCity(){ var kota = $('#select_propinsi').val(); if(kota != ""){ $('#select_propinsi').attr('disabled', true); $.post('<?php echo _SPPATH; ?> ' + 'JNEUtil/getCity', {prop: kota}, function (data) { $('#select_propinsi').attr('disabled', false); $('#citycon').show(); $('#select_kota').html(data); }); }//if kota not empty } </script> <div id="prop_con" class="form-group"> <label class="col-sm-2 control-label" for="input_postal">Propinsi</label> <div class="col-sm-10"> <select class="form-control" onchange="getCity();" id="select_propinsi"> <option value=""></option> <?php foreach ($prop as $loc) { ?> <option value="<?php echo $loc->lokasi_propinsi; ?> "><?php echo $loc->lokasi_nama; ?> </option> <?php } ?> </select> <div id="prop_err" class="noshow">Propinsi must be filled</div> </div> </div> <div class="form-group" id='citycon' style="display: none;"> <label class="col-sm-2 control-label" for="input_postal">City</label> <div class="col-sm-10"> <select class="form-control" onchange="checkOngkir();" id="select_kota"> <option value=""></option> <?php $mail = new JNEUtil(); foreach ($mail->arrKota as $kota) { ?> <option value="<?php echo $kota; ?> "><?php echo $kota; ?> </option> <?php } ?> </select> <div id="jne_sp" style="display: none; font-size: 20px; font-weight: bold; padding: 10px;">Shipping Cost Updated!!</div> <div id="kota_err" class="noshow">City must be filled</div> <div id="jne_div" style="display: none;"> Shipping Cost : <span id="jne_price"></span> <span id="jne_price_hidden" style="display: none"></span> </div> </div> </div> <?php }