首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

请大伙儿帮忙看下

2011-12-06 
请大家帮忙看下我出现了一个问题就是选择药品名称时,可以出现它的药品规格和药品价格相对应记录,但是刷新

请大家帮忙看下
我出现了一个问题就是选择药品名称时,可以出现它的药品规格和药品价格相对应记录,但是刷新页面得到的不是我选择的药品名称.而是出现的刚进入界面的(请选择药品名称).怎么样修改呢?我把代码贴出来了,谢谢了,毕业设计等着急.
<%@   page   import= "java.sql.*,java.util.* "%>
<%@   include   file= "../include/ccs.inc "%>
<%@   page   language= "java "
import= "java.util.*,com.mytest.Hospital.Patient,com.mytest.Hospital.Doctor,com.mytest.Hospital.Drug "
pageEncoding= "gbk "%>
<%@   page   contentType= "text/html;charset=GBK "%>
<jsp:useBean   id= "NurseBeanBusiness "
class= "com.mytest.Hospital.NurseBean "   scope= "page "> </jsp:useBean>

<jsp:useBean   id= "patient "   class= "com.mytest.Hospital.Patient "
scope= "page "> </jsp:useBean>
<jsp:useBean   id= "drug "   class= "com.mytest.Hospital.Drug "   scope= "page "> </jsp:useBean>
<jsp:setProperty   name= "patient "   property= "* "   />
<html>
<head>
<script   language= "javascript ">
function   show(drug_name)

{
var   url   =   "InputEveryDayInfo.jsp?drug_name= "   +   drug_name;
    window.location=url;

}

 
function   change(drug_name)
{
   
    var   url= "InputEveryDayInfo.jsp "
    var   url1= "InputEveryDayItemInfo.jsp "
  if(window.confirm( "是否还需要添加药品? ")){      
  window.location=url;
 
                return       url;      
            }      
            window.location=url1;
  return     url1;
         
}
</script>
</head>



<body   bgcolor= "#FFFFFF ">

<%

double   drug_cost=0;
String   drug_basic_unit= " ";
String   drug_name=request.getParameter( "drug_name ");
if(drug_name==null||drug_name.equals( " "))
{
drug_name= "请选择药品名字 ";
}
else{
byte   b[]=drug_name.getBytes( "ISO-8859-1 ");
        drug_name=new   String(b);}
Iterator   it1   =   NurseBeanBusiness.getdrugotherInfo(drug_name);
while   (it1.hasNext())   {
Drug   drug2   =   (Drug)   it1.next();
  drug_cost=drug2.getDrugCost();
  drug_basic_unit=drug2.getDrugBasicUnit();
}


   
  %>

<table   width= "770 "   height= "423 "   border= "0 "   align= "center "
cellpadding= "0 "   cellspacing= "1 "   bgcolor= "#000000 ">
<tr>
<td   height= "421 "   bgcolor= "#FFFFFF ">
<table   width= "770 "   border= "0 "   align= "center "   cellpadding= "0 "
cellspacing= "0 ">
<tr>
<td>
<br>
&nbsp;
</td>


<td   width= "411 ">
&nbsp;
</td>
</tr>
<tr>
<td   width= "359 ">
<img   src= "/Hospital/images/LEFTBAR.gif "   width= "359 "   height= "39 ">
</td>
<td   align= "right "   bgcolor= "336CA1 ">
&nbsp;
</td>
</tr>
<tr>
<td   colspan= "2 ">
<img   src= "/Hospital/images/TOPBAR.gif "   width= "770 "   height= "69 ">
</td>
</tr>
<tr>
<td   colspan= "2 ">

<table   width= "770 "   height= "290 "   border= "0 "   align= "center "
cellpadding= "0 "   cellspacing= "0 ">
<tr>
<%@   include   file= "../include/nurse.inc "%>
<td   width= "603 "   align= "center "   valign= "top ">
<table   width= "100% "   height= "85% "   border= "0 "   cellpadding= "3 "
cellspacing= "1 "   bgcolor= "#666666 ">
<tr>
<td   width= "100% "   height= "257 "   align= "left "   valign= "top "
bgcolor= "E3EDFF ">
<br>
<center>
<form   action= "showAllInputInfo.jsp "   name= "queryinfo "
method= "POST ">
<%
Drug   drug1   =   new   Drug();
%>
<p>
病人id:
<input   type= "text "   name= "patient_name ">
</p>
<table   width=500   align=center   border= "1 ">
<tr   id= " <%=drug1.getDrugName()%> ">
<td>
<select   name= "drug_name "   onchange= "show(this.value) ">
<option   value= " "> 请选择药品名称 </option>

<%
Iterator   it   =   NurseBeanBusiness.getAlldrug();
while   (it.hasNext())   {
drug1   =   (Drug)   it.next();
drug_name=drug1.getDrugName();
%>

<option   value= <%=drug_name%> >
<%=drug_name%>
</option>

<%
}
%>
</select>
</td>
<td>
药品规格:
<input   type= "text "   name= "drug_basic_unit "   value= <%=drug_basic_unit   %> >
</td>
<td>
药品价格:


<input   type= "text "   name= "drug_cost "   value= <%=drug_cost   %> >

</td>
</tr>
</table>

<p>
<input   type=button   value= "提交 "   onClick= "change( <%drug1.getDrugName();   %> ); ">
</form>
</center>

</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>




[解决办法]
根据你的描述,可以得出以下推断:

得到的药品名称是:“请选择药品”
你可以在提交前用JAVASCRIPT把 选择药品的下拉列表值打出来看看是否为默认

还有可能就是你代码问题,把药品这个变量变成了常量

热点排行