Provincial Urban linkage

Source: Internet
Author: User

HTML section

<tr> <th class= "TextAlign" > Your city </th> <td> <select name= "PR ovince_id "class=" select "> <?phpif(er->province_id):?> <option value= "<?= er->province_id?>" ><?= er-&G T;strprovincename ()?></option> <?phpElse:?> <option value= "" > Please select </option> <?php endif;?> <?phpif(Isset ($province) && count ($province)):?> <?php foreach ($province as $key = $val):? &                      Gt <option value= "<?= $key?>" ><?= $val?></option> <?php endforeach;? > <?php endif;? > </select> <select name= "city_id" class= "select" > <?ph Pif(er->city_id):?> <option value= "<?= er->city_id?>" ><?= er->strcit Yname ()?></option> <?phpElse:?> <option value= "" > Please select </option> <?php endif;?> </select> <select name= "country_id" class= "select" > <?phpif(er->country_id):?> <option value= "<?= er->country_id?>" ><?= er Strcountryname ()?></option> <?phpElse:?> <option value= "" > Please select </option> <?php endif;?> </select> </td> </tr>

JS Section Code

$ (' select[name= ' province_id "]). Change (function() {$.get (' <?=url (' city/city ')?> ', {' province_id ': $ (this). Val ()}, function (data) {if(data.length===0) {alert (' Not found in subordinate cities '); return; }                  $(' Select[name= ' city_id "] '). empty (); $(' Select[name= ' city_id "]). Append (" <option value= ' 0 ' > Please select Province </option> ");  for(varIinchdata) {                      $(' Select[name= ' city_id "]). Append (' <option value= ' ' +data[i].id+ '" > ' +data[i].name+ ' </option> ');          }              });          }); $(' Select[name= ' city_id "]). Change (function() {$.get (' <?=url (' city/country ')?> ', {' city_id ': $ (this). Val ()}, function (data) {if(data.length===0) {alert (' Not found in subordinate cities '); return; }                   $(' Select[name= ' country_id "] '). empty (); $(' Select[name= ' country_id "]). Append (" <option value= ' 0 ' > Please select Province </option> ");  for(varIinchdata) {                      $(' Select[name= ' country_id "]). Append (' <option value= ' ' +data[i].id+ '" > ' +data[i].name+ ' </option> ');          }              }); });

Provincial Urban linkage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.