Home >Backend Development >PHP Tutorial >数据库三级联动如何做
数据库三级联动怎么做
这么做到选择国家的时候省市和市区显示 选择市区的时候出现省市和国家的选择 。
<form action="city.php?module=add" method="Post" name='frmdirection' id='frmdirection'><br /> <input type="hidden" name="id" value="{$data.id}" id="uid"/><br /> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="ttbb2"><br /><br /> <tr><br /> <td width="40%" align="right" bgcolor="#e9f4ff"><strong>地区/行政区域</strong></td><br /> <td><br /> <input type="radio" name="pos_occu" value="2" {if $data.parentid eq "" or $data.parentid neq "99999"}checked="checked"{/if} onclick="clickRadio()"/>地区<br /> <input type="radio" name="pos_occu" value="0" {if $data.parentid eq "" or $data.parentid neq '99999'}checked="checked"{/if} onclick="clickRadio()"/>省份<br /> <input type="radio" name="pos_occu" value="1" {if $data.parentid eq '99999'}checked="checked"{/if} onclick="clickRadio()"/>国家<br /> <br /> </td><br /> </tr><br /> <tr><br /> <td width="40%" align="right" bgcolor="#e9f4ff"><strong>名称</strong></td><br /> <td><input type ="text" class="txt150" name = "data[name]" value="{$data.name}" id="name"><br /> </td><br /> </tr><br /> <tr ><br /> <td width="40%" align="right" bgcolor="#e9f4ff"><strong>所属国家</strong></td><br /> <td><br /> <select name = "data[parentid]" id="parentid" {if $data.parentid neq '99999'} style="max-width:90%"{else}style="display:none"{/if}><br /> {foreach from=$parent item=item key=index}<br /> <option value="{$item.id}"<br /> {if $item.id eq $data.parentid && $data.parentid neq ""}<br /> selected="selected"<br /> {/if}<br /> >{$item.name} </option><br /> {/foreach}<br /><br /> </select><br /> </td><br /> </tr> <br /> <tr ><br /> <td width="40%" align="right" bgcolor="#e9f4ff"><strong>所属省份</strong></td><br /> <td><br /> <select name = "data[parentid]" id="parentid" {if $data.parentid neq "99999"}style="display:block"{else}style="display:none"{/if}><br /> {foreach from=$parent item=item key=index}<br /> <option value="{$item.id}"<br /> {if $item.id eq $data.parentid && $data.parentid neq ""}<br /> selected="selected"<br /> {/if}<br /> >{$item.name} </option><br /> {/foreach}<br /><br /> </select><br /> </td><br /> </tr> <br /></table><br /></form><br />