有两个表producttype 和productproducttype :product
product中的_id对应producttype的id要求选择第一个菜单中的producttype的选项后 第二个菜单显示相对应的 product

解决方案 »

  1.   

    对着这个做的 整的头都大了 还没整出来
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
    <head>
    <head>
    <title>  </title>
    <meta http-equiv="content-type" content="text/html; charset=gb2312" /></head>
    <body>
    <select id="Distinction" name="Distinction" size="1" onchange="Redirect(this.options.selectedIndex)">
    <option selected value="0">选择类型</option> 
    <option value="购买">购买</option> 
    <option value="消耗">消耗</option> </select>
    <select id="purpose" name="purpose" size="1">
    <option value="1">选择类型</option>
    </select>
    <script type="text/javascript">
    <!--
    var groups = document.getElementById("Distinction").options.length;
    var group = new Array(groups)
    for (i = 0; i < groups; i ++)
    group[i] = new Array()group[0][0] = new Option("选择类型","0")group[1][0] = new Option("购买券","购买券")
    group[1][1] = new Option("物换券","物换券")
    group[1][2] = new Option("兑换券","兑换券")group[2][0] = new Option("券换物","券换物")
    group[2][1] = new Option("兑换券","兑换券")var temp = document.getElementById("purpose");
    function Redirect(x){ for (m = temp.options.length-1; m > 0; m --)
     temp.options[m] = null
     for (i = 0; i < group[x].length; i ++){
     temp.options[i] = new Option(group[x][i].text,group[x][i].value);
      
     }
     
     temp.options[0].selected = true
    }
    //-->
    </script></body>
    </html>
      

  2.   

    用ajax做。选择producttype的选项后,触发onchange事件,传递product表的_id给后台页面,后台页面查询到相关信息后,返回查询到的数据,然后用js填充数据。
      

  3.   

    producttype 的下拉框保存 id  onchange 提交ajax查询 取传过来的id查询 返回json 前台循环这个json
                   
     $("#product").find("option").remove();      //先移除产品原有的选项
                    if (msg == "") return;
                    var json = eval('(' + msg + ')');
                    for (var i = 0; i < json.length; i++) {
                        $("#product").append('<option value="' + json[i].autoid + '">' + decodeURI(json[i].uname) + '</option>');
                    }
      

  4.   

    解决了 <?php include 'inc/conn.php';?>
    <title></title>
    <script language="JavaScript">
    <!-- 
       var reobj = null;
    var http_request = false;if(window.XMLHttpRequest){ 
    http_request=new XMLHttpRequest();
        if(http_request.overrideMimeType){
        http_request.overrideMimeType("text/xml");
        }
    }
    else if(window.ActiveXObject){ 
        try{
        http_request=new ActiveXObject("Msxml2.XMLHttp");
        }catch(e){
          try{
          http_request=new ActiveXobject("Microsoft.XMLHttp");
          }catch(e){}
          }
        }   function send_request(url){ 
        if(!http_request){
        window.alert("创建XMLHttp对象失败!");
        return false;
        }
    http_request.open("GET",url,true);
    http_request.onreadystatechange=processrequest;
    http_request.send(null);
    }//处理返回信息的函数
    function processrequest(){
       if(http_request.readyState==4){ //判断对象状态
         if(http_request.status==200){ //信息已成功返回,开始处理信息
         document.getElementById(reobj).innerHTML=http_request.responseText;
    }
    else{
         alert("您所请求的页面不正常!");
         }
       }
    }
        
    function getclass(obj){
       var pid=document.form1.select1.value;   document.getElementById(obj).innerHTML="<option>loading...</option>";
       reobj=obj;   
       send_request("newfile.php?pid="+pid);
       }
    //-->
    </script>
    </head><body>
    <form name="form1"><select name="select1" id="class1"  onChange="getclass('class2');">
    <option selected="selected">请选择大类</option><?php 
    $sql=mysql_query("select * from producttype");
    while ($row=mysql_fetch_array($sql)){
      ?><option value="<?php echo $row['Id']?>"><?php echo $row['name']?></option> 
    <?php }
    ?>
    </select>
    <div id="class2">
    </div>
    </form></body>newfile:
    <?php
    include("inc/conn.php");
    $pid=$_GET['pid'];$sql=mysql_query("select * from product where _id=$pid");?>
    <select id="product" name="product" size="1">
    <?php 
    //循环列出选项
    while($rows=mysql_fetch_array($sql))
    {
    ?>
    <option value="1"><?php echo $rows['name']?></option>
    <?php 
    }?>
    </select>