v2.5.2
Giriş yap

Json formatında mahalle verisi

yazilimyolcusu
169 defa görüntülendi

Arkadaşlar merhaba. Yapmakta olduğum emlak sitesinin bir eksiği var, mahalle kısmı. Aşağıdaki kodlarla insert, edit, update ve delete yapabiliyorum. Ama mahalleyi de eklemem lazım. Elinde aşağıdaki kodlara uyarlanabilecek json formatında mahalle verisi olan var mı arkadaşlar?

<select name="il" id="il" onChange="set_child_listbox('il', 'ilce',ilceler,1,0);"
   required="required">
   <option value=""><?php echo $dil["a18"]; ?></option>
   <Option Value="İstanbul">İstanbul</Option>
   <Option Value="Ankara">Ankara</Option>
   <Option Value="İzmir">İzmir</Option>
   <Option Value="Adana">Adana</Option>
   <Option Value="Adıyaman">Adıyaman</Option>
   <Option Value="Afyon">Afyon</Option>
   <Option Value="Ağrı">Ağrı</Option>
   <Option Value="Aksaray">Aksaray</Option>
   <Option Value="Amasya">Amasya</Option>
   <Option Value="Antalya">Antalya</Option>
   <Option Value="Ardahan">Ardahan</Option>
   <Option Value="Artvin">Artvin</Option>
   <Option Value="Aydın">Aydın</Option>
   <Option Value="Balıkesir">Balıkesir</Option>
   <Option Value="Bartın">Bartın</Option>
   <Option Value="Batman">Batman</Option>
   <Option Value="Bayburt">Bayburt</Option>
   <Option Value="Bilecik">Bilecik</Option>
   <Option Value="Bingöl">Bingöl</Option>
   <Option Value="Bitlis">Bitlis</Option>
   <Option Value="Bolu">Bolu</Option>
   <Option Value="Burdur">Burdur</Option>
   <Option Value="Bursa">Bursa</Option>
   <Option Value="Çanakkale">Çanakkale</Option>
   <Option Value="Çankırı">Çankırı</Option>
   <Option Value="Çorum">Çorum</Option>
   <Option Value="Denizli">Denizli</Option>
   <Option Value="Diyarbakır">Diyarbakır</Option>
   <Option Value="Düzce">Düzce</Option>
   <Option Value="Edirne">Edirne</Option>
   <Option Value="Elazığ">Elazığ</Option>
   <Option Value="Erzincan">Erzincan</Option>
   <Option Value="Erzurum">Erzurum</Option>
   <Option Value="Eskişehir">Eskişehir</Option>
   <Option Value="Gaziantep">Gaziantep</Option>
   <Option Value="Giresun">Giresun</Option>
   <Option Value="Gümüşhane">Gümüşhane</Option>
   <Option Value="Hakkari">Hakkari</Option>
   <Option Value="Hatay">Hatay</Option>
   <Option Value="Iğdır">Iğdır</Option>
   <Option Value="Isparta">Isparta</Option>
   <Option Value="Kahramanmaraş">Kahramanmaraş</Option>
   <Option Value="Karabük">Karabük</Option>
   <Option Value="Karaman">Karaman</Option>
   <Option Value="Kars">Kars</Option>
   <Option Value="Kastamonu">Kastamonu</Option>
   <Option Value="Kayseri">Kayseri</Option>
   <Option Value="Kırıkkale">Kırıkkale</Option>
   <Option Value="Kırklareli">Kırklareli</Option>
   <Option Value="Kırşehir">Kırşehir</Option>
   <Option Value="Kilis">Kilis</Option>
   <Option Value="Kocaeli">Kocaeli</Option>
   <Option Value="Konya">Konya</Option>
   <Option Value="Kütahya">Kütahya</Option>
   <Option Value="Malatya">Malatya</Option>
   <Option Value="Manisa">Manisa</Option>
   <Option Value="Mardin">Mardin</Option>
   <Option Value="Mersin">Mersin</Option>
   <Option Value="Muğla">Muğla</Option>
   <Option Value="Muş">Muş</Option>
   <Option Value="Nevşehir">Nevşehir</Option>
   <Option Value="Niğde">Niğde</Option>
   <Option Value="Ordu">Ordu</Option>
   <Option Value="Osmaniye">Osmaniye</Option>
   <Option Value="Rize">Rize</Option>
   <Option Value="Sakarya">Sakarya</Option>
   <Option Value="Samsun">Samsun</Option>
   <Option Value="Siirt">Siirt</Option>
   <Option Value="Sinop">Sinop</Option>
   <Option Value="Sivas">Sivas</Option>
   <Option Value="Şanlıurfa">Şanlıurfa</Option>
   <Option Value="Şırnak">Şırnak</Option>
   <Option Value="Tekirdağ">Tekirdağ</Option>
   <Option Value="Tokat">Tokat</Option>
   <Option Value="Trabzon">Trabzon</Option>
   <Option Value="Tunceli">Tunceli</Option>
   <Option Value="Uşak">Uşak</Option>
   <Option Value="Van">Van</Option>
   <Option Value="Yalova">Yalova</Option>
   <Option Value="Yozgat">Yozgat</Option>
   <Option Value="Zonguldak">Zonguldak</Option>
</select>


<select name="ilce" id="ilce" required="required" class="validate[required]">
   <option value=""><?php echo $dil["a18"]; ?></option>
</select>


<script>
   function findObj(n, d) { //v4.01
      var p, i, x;
      if (!d) d = document;
      if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
         d = parent.frames[n.substring(p + 1)].document;
         n = n.substring(0, p);
      }
      if (!(x = d[n]) && d.all) x = d.all[n];
      for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
      for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
      if (!x && d.getElementById) x = d.getElementById(n);
      return x;
   }

   function MM_findObj(n, d) { //v4.01
      var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
         d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
      }
      if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
      for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
      if (!x && d.getElementById) x = d.getElementById(n); return x;
   }


   var ilceler = new Array(new Array('Adana', 'Aladağ'),
      new Array('Adana', 'Ceyhan'),
      new Array('Adana', 'Feke'),
      new Array('Adana', 'İmamoğlu'),
      new Array('Adana', 'Karaisalı'),
      new Array('Adana', 'Karataş'),
      ...
      new Array('Yozgat', 'Şefaatli'),
      new Array('Yozgat', 'Yenifakılı'),
      new Array('Yozgat', 'Yerköy'),
      new Array('Zonguldak', 'Merkez'),
      new Array('Zonguldak', 'Alaplı'),
      new Array('Zonguldak', 'Çaycuma'),
      new Array('Zonguldak', 'Devrek'),
      new Array('Zonguldak', 'Ereğli'),
      new Array('Zonguldak', 'Gökçebey'));
      ...
      var semtler = new Array();
      function set_child_listbox(sSource, sTarget, childArray, sifirla, tip) {
         //önce temizlik ;)
         var parentObject = findObj(sSource);
         var childObject = findObj(sTarget);
         var base = 0;
         if (sifirla == 1) {
            base = -1;
         } else {
            base = 0;
         }

         for (var i = childObject.length; i > base; i--) {
            childObject.options[i] = null;
         }

         //childObject.options[0] = new Option("Seçiniz","");
         //var selIndex = parentObject.options[parentObject.selectedIndex].value;
         var selIndex = parentObject.value;
         if (selIndex == "") {
            //childObject.disabled = true;
         } else {
            childObject.disabled = false;
            var childIndex = base + 1;
            for (i = 0; i < childArray.length; i++) {
               if (childArray[i][0 + tip] == selIndex) {
                  childObject.options[childIndex + 1] = new Option(childArray[i][1 + tip], childArray[i][1 + tip]);
                  childIndex++;
               }
            }
         }

         childObject.selectedIndex = 0;
         if (document.getElementById('nvar_alan_1').value == 'Türkiye' || document.getElementById('nvar_alan_1').value == '') { childObject.focus(); } else { document.getElementById('ilce').style.display = 'none'; document.getElementById('nvar_alan_4').style.display = 'block'; document.getElementById('nvar_alan_5').style.display = 'block'; }
      }
</script>
Cevap yaz
Cevaplar (1)
terso
96 gün önce

şöyle bir şey gördü github'da. Bi bakmanı tavsiye ederim
https://github.com/metinyildirimnet/turkiye-adresler-json