`
qianchengboy
  • 浏览: 48468 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

DWR 三级联动

阅读更多
首先引入所需的 js
<script src='项目名/dwr/interface/GetTrade.js'></script> 一定要加上项目名否则会有异常发生
<script src='项目名/dwr/interface/GetArea.js'></script>
<script src='项目名/dwr/engine.js'></script>
<script type='text/javascript' src='项目名/dwr/util.js'></script>

<script type="text/javascript">
<!--
function getSecondTrade(value)
{
    if(value!="" || value!=null){
GetTrade.getSecondTrade(value,setSecondTrade);
    }
}
function setSecondTrade(data)
{
     var tradesecond=$("tradesecond");
     DWRUtil.removeAllOptions(tradesecond);
     DWRUtil.addOptions(tradesecond,{'':'请选择'});
     DWRUtil.addOptions(tradesecond,data);
}

function getThirdTrade(value)
{
if(value!="" || value!=null){
GetTrade.getThirdTrade(value,setThirdTrade);
}
}
function setThirdTrade(data)
{
var tradethird=$("tradethird");
DWRUtil.removeAllOptions(tradethird);
DWRUtil.addOptions(tradethird,{'':'请选择'});
DWRUtil.addOptions(tradethird,data);
}

function getCity(value)
{
if(value!="" || value!=null){
GetArea.getCity(value,setCity);
}
}
function setCity(data)
{
var city=$("city");
DWRUtil.removeAllOptions(city);
DWRUtil.addOptions(city,{'':'请选择'});
DWRUtil.addOptions(city,data);
}

function getCountry(value)
{
if(value!="" || value!=null){
GetArea.getCounty(value,setCountry);
}
}
function setCountry(data)
{
var country=$("country");
DWRUtil.removeAllOptions(country);
DWRUtil.addOptions(country,{'':'请选择'});
DWRUtil.addOptions(country,data);
}
//-->
</script>

html 代码
<td><div align="right">行业分类:</div></td>
<td colspan="3">
<html:select property="tradefirst" onchange="getSecondTrade(this.value)">
  <logic:present name="tradecollection" scope="session">
<html:options labelProperty="sme_first_classname" property="id" collection="tradecollection"></html:options>
  </logic:present>
</html:select>
<html:select property="tradesecond" onchange="getThirdTrade(this.value)">
<html:option value="${requestScope.companyForm.tradesecond}"><bean:write name="companyForm" 
property="tradesecondname"/></html:option>
</html:select>      
<html:select property="tradethird">
<html:option value="${requestScope.companyForm.tradethird}"><bean:write name="companyForm" property="tradethirdname"/></html:option>
</html:select>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics