zoukankan      html  css  js  c++  java
  • 下拉框获取关联表的信息

    用jq和ajax实现

    1.在jsp页面上

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

    $(function(){
            $.get("productType1_findAll.action",function(data){    -------->从自己的action中查询,返回productTypeList
                $.each(data.productTypeList,function(i,element){
                    var productId='${productId}';
                    if(productId==element.id){
                        $("#productId").append("<option value='"+element.id+"'selected>"+element.productTypeName+"</option>");
                    }else{
                        $("#productId").append("<option value='"+element.id+"' >"+element.productTypeName+"</option>");
                    }                
                })
            },"json")
        })

    ------------------------------------------------------------------------------------------------------------------------------------

    <div class="field">
                <select name="productId" id="productId" class="input w50">
                  <option value="">请选择</option>   
                </select>
                <div class="tips"></div>
              </div>

  • 相关阅读:
    jQuery 删除元素
    jQuery 添加元素
    jQuery 捕获
    jQuery 链
    jQuery Callback
    jQuery 停止动画
    jQuery 动画
    jQuery 滑动
    jQuery 淡入淡出
    SP2010开发和VS2010专家"食谱"--第七章节--使用客户端对象模型
  • 原文地址:https://www.cnblogs.com/lbloveab/p/7214439.html
Copyright © 2011-2022 走看看