<%
  String feastname="";
  String gname="";
  String gimage="";
  String gsid="";
  //三天后即将到来的节日
  db.executeQuery("getFeastInfo","SELECT goodsid,goodsname,goodsimage,goodsmoney,description FROM goods_info WHERE typeid='2' AND month(startdate)=month(now()) AND (dayofmonth(now())-dayofmonth(startdate))>=0 AND (dayofmonth(now())-dayofmonth(startdate))<=3");
 while(db.next("getFeastInfo"))
 {
   gsid=db.getString("getFeastInfo","goodsid");
   feastname=db.getString("getFeastInfo","description");
   gname=db.getString("getFeastInfo","goodsname");
   gimage=db.getString("getFeastInfo","goodsimage");
   %>
    <dl class="pd_dl">
    <dd class="dd1"><a href="#"><%=gname %></a></dd>
    <dd class="dd1"><a href="#"><%=feastname %></a></dd>
    <dd class="dd1 btn"><a onclick="show(<%=gsid %>)"><img src="images/present/as1.gif" /></a></dd>//弹出一个层,把gsid传到层中,并在层中显示gsid的信息....
    </dl>
    <%
  }
  //这是显示信息的层
  <br><div id="divTest" class="alogin" >
 <div class="atop">
  <img src="images/present/al_1.gif" width="484" border="0" usemap="#Map" />
   <map name="Map" id="Map">
   <area shape="circle" coords="466,17,12" href="javascript:;"  onclick="closes();"/>
   </map>
 </div>
 <div class="amain">
  <%
   String gid=request.getParameter("goodsid");
   System.out.print("----------"+gid);
   String goodsname="";
   db.executeQuery("get","SELECT * FROM goods_info where goodsid='"+gid+"'");
   while(db.next("get"))
   {
    goodsname=db.getString("get","goodsname");
   }
  %>
  <div class="adetail" id="info">
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="11%" align="center" valign="top" class="pre_detail">赠言:</td>
        <td width="89%" rowspan="2"><span id="reText"><%=goodsname %></span><textarea cols="45" rows="5" name="content" id="content"></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="25" colspan="2" align="center"><a  onClick="JScript:submit();" ><img src="images/present/b1.gif" height="21"/></a>&nbsp;&nbsp;<a href="javascript:;" onclick="closes();"><img src="images/present/b2.gif" /></a></td>
      </tr>
   </table>
</div>
</div>
</div>
</div>
<div id="ly" class="mask">
</div>        
      
%>
gsid通过ajax传过去
以下是ajax代码
 <script type="text/javascript">              
            var xmlHttp;     
            function createXMLHttpRequest() {
                //表示当前浏览器不是ie,如ns,firefox
                if(window.XMLHttpRequest) {
                    xmlHttp = new XMLHttpRequest();
                } else if (window.ActiveXObject) {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
            }
            
    
            
function show(goodsid)
{
    
document.all.ly.style.display="block";   
document.all.ly.style.width=document.body.clientWidth+20;
document.all.ly.style.height=document.body.clientHeight+20;
document.all.divTest.style.display='block';   
document.getElementById("divTest").style.visibility="visible";
//var url = "MyJsp.jsp?goodsid="+goodsid;
createXMLHttpRequest();
//ajax 要受缓存影响 "&timestamp=" + new Date().getTime() 使得每次时间都不同 而不使用缓存内容
 //注意这个url 我刚才拼错了几次  晕 function sendAjaxRequest(goodsid)这样传递参数我的报错  换个方法 我
  var url ="MyJsp.jsp?goodsid="+goodsid+"&timestamp=" + new Date().getTime();
  xmlHttp.open("get",url,true);//我写的这个是true
  xmlHttp.onreadystatechange = processResponse;//指定响应函数
  xmlHttp.send(null);
  window.alert(goodsid);
}            function processResponse() {
              if(xmlHttp.readyState==4) {
                 if(xmlHttp.status==200) {
                 //这里用innertHTML写入到<span id="reText"></span> 
                   reText.innerHTML = + xmlHttp.responseText;
                   }else {
                    window.alert("所请求的页面有异常");
                 }
              }           
            }
        
           
        
    </script>
但页面没有效果!什么原因啊?高手帮忙看看,好急啊!都快崩溃了!最后的20分了!帮忙///

解决方案 »

  1.   

    var url ="MyJsp.jsp?goodsid="+goodsid+"&timestamp=" + new Date().getTime();URL的问题啦!
    如果是你的WEBROOT下的JSP的话 url="{pageContext.request.contextPath}/MyJsp.jsp?goodsid="+goodsid+"&timestamp=" + new Date().getTime();
      

  2.   

    我想要的效果就是点击一按钮弹出一个层,点击按钮的同时把id值传到层里,然后在层中显示相对应id的物品信息!能不能不使用ajax就实现这样的功能