<script language='javascript' src='class/twzipcode-1.3.1.js'></script> <script type='text/javascript'> $(document).ready(function() { $('#AddrForm').twzipcode({ countyName: '縣市欄位的name', areaName: '鄉鎮市區欄位的name', zipName: '郵遞區號欄位的name', countySel: '$縣市預設值', areaSel: '$鄉鎮市區預設值', zipSel: '$郵遞區號預設值', zipReadonly: false }); }); </script>
<div style='position:relative;'> <span id='AddrForm'></span> <input type='text' name='addr' size='30' value='{$addr}' id='addr'> </div>
$('#menu2').change(function(){ $.post('ajax.php' , {op: contact_list , gsn: $('#menu2').val()} , function(data){ $('#contact_list').html(data); }); });
$gsn=empty($_POST['gsn'])?0:$_POST['gsn']; $op=empty($_POST['op'])?'':$_POST['op']; switch($op){ case "contact_list": echo contact_list($gsn); break; } function contact_list($gsn=''){ //根據$gsn去資料庫撈出相關資料,基本上就是index.php的list_contact()函數內容 }
$('#menu1').change(function(){ $.post('ajax.php' , {parent_gsn: $('#menu1').val()} , function(data){ $('#menu2').html(data); $.post('ajax.php' , {op: 'contact_list' , gsn: $('#menu2').val()} , function(data){ $('#contact_list').html(data); }); }); });