<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-200  評論-148  文章-15  trackbacks-0

    這個是我看到的,做個備份,大家共享?;蛟S大家覺得簡單,別笑話我。原文出處:

    http://www.javalaw.cn/forum/read.php?tid=109&fpage=1

    ava實(shí)現(xiàn)版本:首先選擇產(chǎn)品分類,然后選擇產(chǎn)品類型
    jsp:
    1.queryProduct.jsp

    CODE:
    ......
    ? <script type="text/javascript" src="../js/taconite-client.js"></script>
    ? <script type="text/javascript" src="../js/taconite-parser.js"></script>
    ? <script language="javascript">
    ? ? //選擇產(chǎn)品分類
    ? ? function selectCatalog(vproductCatalog) {
    ? ? ? ? if (vproductCatalog.value == "") {
    ? ? ? ? ? hint("請先選擇產(chǎn)品分類");
    ? ? ? ? } else {
    ? ? ? ? ? hint("加載中...");
    ? ? ? ? ? var ajaxRequest = new AjaxRequest("<html:rewrite page="/product/queryProductsAction.do"/>");
    ? ? ? ? ? ajaxRequest.setQueryString("catalogId=" + vproductCatalog.value);
    ? ? ? ? ? ajaxRequest.sendRequest();
    ? ? ? ? }
    ? ? }
    ? ? function hint(msg) {
    ? ? ? ? var e = document.getElementById("PTypeSelectList");
    ? ? ? ? while (e.childNodes.length > 0) {
    ? ? ? ? ? e.removeChild(e.childNodes[0]);
    ? ? ? ? }
    ? ? ? ? var option = document.createElement("option");
    ? ? ? ? var text = document.createTextNode(msg);
    ? ? ? ? option.appendChild(text);
    ? ? ? ? e.appendChild(option);
    ? ? }
    ? </script>
    ......
    <table width="600" border="1" cellpadding="0" cellspacing="0" bordercolor="#E7E7E7">
    ? ? ? ? ? <tr>
    ? ? ? ? ? ? <td bgcolor="#F6F6F6" class="t_1"> 產(chǎn)品分類目錄
    ? ? ? ? ? ? <html:select property="productCatalog" onchange="selectCatalog(this)">
    ? ? ? ? ? ? <html:option value ="">請選擇產(chǎn)品分類</html:option>
    ? ? ? ? ? ? <html:options collection ="productCatalogs" property="value" labelProperty="label"/>
    ? ? ? ? ? ? </html:select>
    ? ? ? ? ? ? </td>
    ? ? ? ? ? </tr>
    ? ? ? ? ? <tr>
    ? ? ? ? ? ? <td align="left" class="t_1"> 產(chǎn)品類型目錄
    ? ? ? ? ? ? <html:select property="productType" styleId="PTypeSelectList">
    ? ? ? ? ? ? <html:option value ="">請先選擇產(chǎn)品分類</html:option>
    ? ? ? ? ? ? <html:options collection ="productTypes" property="value" labelProperty="label"/>
    ? ? ? ? ? ? </html:select>
    ? ? ? ? ? ? <html:submit property="query" value="查 詢"/></td>
    ? ? ? ? ? </tr>
    ? ? ? ? ? </table>
    ? ? ? ? ? </html:form>
    [Copy to clipboard]

    2.showProductType.jsp
    CODE:
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="[url]http://java.sun.com/jstl/core[/url]" prefix="c" %>
    <%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
    <%@ taglib uri="[url]http://taconite.sf.net/tags[/url]" prefix="tac" %>
    <tac:taconiteRoot>
    <tac:replaceChildren contextNodeID="PTypeSelectList" parseOnServer="false">
    ? ? ? <option value="" >請選擇產(chǎn)品類型</option>
    ? <nested:iterate id="view" name="productTypes" >
    ? ? ? <option value="<nested:write name="view" property="value" />" ><nested:write name="view" property="label" /></option>
    ? </nested:iterate>
    </tac:replaceChildren>
    </tac:taconiteRoot>
    [Copy to clipboard]

    action:
    CODE:
    public class QueryProductsAction extends Action {
    ? public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) {
    ? ? ......
    ? ? UtilBusiness utilBusiness = new UtilBusinessImpl();
    ? ? request.setAttribute("productCatalogs",utilBusiness.getAllProductCatalogs());
    ? ? int catalogId = 0;
    ? ? if(request.getParameter("catalogId") != null && request.getParameter("catalogId").length != 0){
    ? ? ? ? catalogId = Integer.parseInt(request.getParameter("catalogId"));
    ? ? }
    ? ? request.setAttribute("productTypes",utilBusiness.getAllPTypes(catalogId));
    ? ? return mapping.findForward("showPType");
    ? ? ......
    ? }
    }
    [Copy to clipboard]

    UtilDaoImpl.java:
    CODE:
    public List getAllPTypes(int catalogId) throws DaoException{
    ? ? String getAllProductTypes = "select id,name from productType where catalogId = ?"; ? ? ?
    ? ? Connection con = null;
    ? ? PreparedStatement ps = null;
    ? ? ResultSet rs = null;
    ? ? try {
    ? ? ? ? List list = new ArrayList();
    ? ? ? ? PType pType;
    ? ? ? ? con = super.getConnection();
    ? ? ? ? ps = con.prepareStatement(getAllProductTypes);
    ? ? ? ? ps.setInt(1,catalogId);
    ? ? ? ? rs = ps.executeQuery();
    ? ? ? ? while (rs.next()) {
    ? ? ? ? ? pType = new PType();
    ? ? ? ? ? pType.setLabel(rs.getString("name"));
    ? ? ? ? ? pType.setValue(String.valueOf(rs.getInt("id"));
    ? ? ? ? ? list.add(pType);
    ? ? ? ? }
    ? ? ? ? return list;
    ? ? } catch (SQLException sqle) {
    ? ? ? ? sqle.printStackTrace();
    ? ? } catch (NullPointerException npe) {
    ? ? ? ? npe.printStackTrace();
    ? ? } finally {
    ? ? ? ? ? if (null != rs) {
    ? ? ? ? ? ? rs.close();
    ? ? ? ? ? }
    ? ? ? ? ? if (null != ps) {
    ? ? ? ? ? ? ps.close();
    ? ? ? ? ? }
    ? ? ? ? ? if (null != con) {
    ? ? ? ? ? ? con.close();
    ? ? ? ? ? } ?
    }

    posted on 2006-07-10 12:43 無聲 閱讀(2212) 評論(2)  編輯  收藏 所屬分類: 職場生活

    評論:
    # re: 用ajax如何實(shí)現(xiàn)下拉列表框的聯(lián)動 2006-07-11 09:32 | 小白的一生
    好,希望你能把/product/queryProductsAction.do也全部列出來,呵呵這里是查詢出來的結(jié)果,然后回傳給頁面顯示的下拉值  回復(fù)  更多評論
      
    # re: 用ajax如何實(shí)現(xiàn)下拉列表框的聯(lián)動 2007-10-16 16:41 | 王毅
    不錯  回復(fù)  更多評論
      
    主站蜘蛛池模板: 亚洲精品第一国产综合精品| 亚洲色欲色欲综合网站| a毛片免费全部在线播放**| 亚洲日本在线播放| 国产精品免费视频一区| a级毛片毛片免费观看久潮| 亚洲日本在线观看网址| 亚洲国产天堂久久久久久| 91青青青国产在观免费影视| 亚洲日韩国产精品乱-久| 在线观看亚洲av每日更新| 亚洲天堂免费在线| 无码毛片一区二区三区视频免费播放| 亚洲女初尝黑人巨高清| 成人性生免费视频| 免费久久人人爽人人爽av| 亚洲日韩中文字幕一区| 亚洲精品美女久久久久99小说| 99免费在线观看视频| 麻豆安全免费网址入口| 亚洲成a人片7777| 国产精品xxxx国产喷水亚洲国产精品无码久久一区| 免费日本一区二区| 免费人成网站永久| 亚洲 日韩 色 图网站| 国产亚洲综合成人91精品| 国产片免费在线观看| 免费在线观看视频网站| 巨胸喷奶水视频www免费视频| 亚洲精品天堂在线观看| 久久亚洲伊人中字综合精品| 免费萌白酱国产一区二区| 1000部啪啪毛片免费看| 中文字幕视频在线免费观看| 在线观看亚洲电影| 亚洲国产熟亚洲女视频| 亚洲欧洲国产视频| 亚洲精品美女久久久久9999| 国产成人亚洲精品青草天美| 亚洲国产综合精品中文字幕 | 亚洲已满18点击进入在线观看|