为何选中2号机,点确定按钮页面提交后,
机组选项仍为1号机,各位大侠给点建议,能否不用javascript函数解决问题,多谢
<%@ page language="java" contentType="text/html; charset=gb2312"pageEncoding="gb2312"%>
<%@ page import = "java.util.Date" %>
<% Date date=new Date();
int currentY = date.getYear()+1900;
int currentM = date.getMonth()+1;
int currentD = date.getDate();
String[][] names= { {"1号机","1001"},{"2号机","1002"}};
int unitNum=names.length; String sYear=request.getParameter("year");
String sMonth=request.getParameter("month");
String sDay=request.getParameter("day");
String sUnitId=request.getParameter("bidunit_id");
if (sYear==null) {
sYear=String.valueOf(currentY);
}
if (sMonth==null) {
sMonth=String.valueOf(currentM);
}
if (sDay==null) {
sDay=String.valueOf(currentD);
} if (sUnitId==null) {
System.out.println("sUnitId null......................");
sUnitId=names[0][1]; //第一次默认取第一个机组id
}
String sDate=sYear+"-"+sMonth+"-"+sDay;
int year = Integer.parseInt(sYear);
int month =Integer.parseInt(sMonth);
int day=Integer.parseInt(sDay);
%><body >
<form id="d_gen_form" method="post">
<div>
<table width="100%" border=0>
<tr>
<td style="font-size:14px" colspan=2 height="5" align="right"></td>
</tr>
<tr>
<td style="font-size:14px" align="right" width=70%>
时间:
<select id="year" name="year" style="HEIGHT: 20px; WIDTH:60px">
<%
for (int i=currentY - 5;i<=currentY + 3;i++) {
%>
<option
<%
if (i == year) {
%>
selected
<%
}
%>
> <%=i%>
</option>
<%
}
%>
</select>年
<select id="month" name="month" style="HEIGHT: 20px; WIDTH:60px">
<%
for (int j = 1 ; j <= 12; j++) {
%>
<option
<%
if (j == month) {
%>
selected
<%
}
%>
><%=j%>
</option>
<%
}
%>
</select>月
<select id="day" name="day" style="HEIGHT: 20px; WIDTH:60px"><%
for (int k = 1 ; k <= 31; k++) {
%>
<option
<%
if (k == day) {
%>
selected
<%
}
%>
><%=k%>
</option>
<%
}
%>
</select>日
</td>
<td style="font-size:14px" align="right" width=20%;>
机组:
<select id="bidunit" name="bidunit" style="HEIGHT: 20px;" >
<%
for (int l=0;l<unitNum;l++) {
if (sUnitId == names[l][1]) {
%>
<option selected value="<%=names[l][1]%>">
<%=names[l][0]%>
</option>
<%
} else {
%>
<option value=="<%=names[l][1]%>">
<%=names[l][0]%>
</option>
<%
} }
%>
</select>
</td>
<td width=8% align="right">
<input type="button" value="确定" onClick="submit()">
</td>
</tr>
<tr>
<td style="font-size:13px" colspan=2 align="left">
单位:兆瓦
</td>
</tr>
<tr>
<td style="font-size:14px" colspan=2 height="5"></td>
</tr>
</table>
</div>
</form>
</body>
机组选项仍为1号机,各位大侠给点建议,能否不用javascript函数解决问题,多谢
<%@ page language="java" contentType="text/html; charset=gb2312"pageEncoding="gb2312"%>
<%@ page import = "java.util.Date" %>
<% Date date=new Date();
int currentY = date.getYear()+1900;
int currentM = date.getMonth()+1;
int currentD = date.getDate();
String[][] names= { {"1号机","1001"},{"2号机","1002"}};
int unitNum=names.length; String sYear=request.getParameter("year");
String sMonth=request.getParameter("month");
String sDay=request.getParameter("day");
String sUnitId=request.getParameter("bidunit_id");
if (sYear==null) {
sYear=String.valueOf(currentY);
}
if (sMonth==null) {
sMonth=String.valueOf(currentM);
}
if (sDay==null) {
sDay=String.valueOf(currentD);
} if (sUnitId==null) {
System.out.println("sUnitId null......................");
sUnitId=names[0][1]; //第一次默认取第一个机组id
}
String sDate=sYear+"-"+sMonth+"-"+sDay;
int year = Integer.parseInt(sYear);
int month =Integer.parseInt(sMonth);
int day=Integer.parseInt(sDay);
%><body >
<form id="d_gen_form" method="post">
<div>
<table width="100%" border=0>
<tr>
<td style="font-size:14px" colspan=2 height="5" align="right"></td>
</tr>
<tr>
<td style="font-size:14px" align="right" width=70%>
时间:
<select id="year" name="year" style="HEIGHT: 20px; WIDTH:60px">
<%
for (int i=currentY - 5;i<=currentY + 3;i++) {
%>
<option
<%
if (i == year) {
%>
selected
<%
}
%>
> <%=i%>
</option>
<%
}
%>
</select>年
<select id="month" name="month" style="HEIGHT: 20px; WIDTH:60px">
<%
for (int j = 1 ; j <= 12; j++) {
%>
<option
<%
if (j == month) {
%>
selected
<%
}
%>
><%=j%>
</option>
<%
}
%>
</select>月
<select id="day" name="day" style="HEIGHT: 20px; WIDTH:60px"><%
for (int k = 1 ; k <= 31; k++) {
%>
<option
<%
if (k == day) {
%>
selected
<%
}
%>
><%=k%>
</option>
<%
}
%>
</select>日
</td>
<td style="font-size:14px" align="right" width=20%;>
机组:
<select id="bidunit" name="bidunit" style="HEIGHT: 20px;" >
<%
for (int l=0;l<unitNum;l++) {
if (sUnitId == names[l][1]) {
%>
<option selected value="<%=names[l][1]%>">
<%=names[l][0]%>
</option>
<%
} else {
%>
<option value=="<%=names[l][1]%>">
<%=names[l][0]%>
</option>
<%
} }
%>
</select>
</td>
<td width=8% align="right">
<input type="button" value="确定" onClick="submit()">
</td>
</tr>
<tr>
<td style="font-size:13px" colspan=2 align="left">
单位:兆瓦
</td>
</tr>
<tr>
<td style="font-size:14px" colspan=2 height="5"></td>
</tr>
</table>
</div>
</form>
</body>
解决方案 »
- 如何给产品添加附加属性?产品附加属性了怎么做?
- 谁可以说一下 用友致远oa系统的技术
- 如何向text文本框中导入excel表中的数据?
- struts2上传图片到数据库验证方面的问题
- Tomcat 经常死机 Tomcat 作WEB服务器怎么这么不稳定,各位帮看看什么原因
- 构造无限级树的递归函数问题
- 判断session失效的问题 jsp + tomcat
- java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagExtraInfo
- 看偶做的树形菜单(右键可配置,动态加载)(IP地址动态分配的)
- 高分求救!二级菜单问题
- 问两个问题?
- 请问哪位高人可以把这段JAVASCRIPT代码转换成VC代码(加分或RMB都可以)
if (sUnitId==null) {
System.out.println("sUnitId null......................");
sUnitId=names[0][1]; //第一次默认取第一个机组id
}
如何处理啊,大侠帮忙,好久不搞技术了,JSP忘了
for (int l=0;l <unitNum;l++) { if (sUnitId == names[l][1]) { ==>sUnitId.equals(names[l][1]);
% >
<option selected value=" <%=names[l][1]% >" >
<%=names[l][0]% >
</option >
<%
} else {
% >
<option value==" <%=names[l][1]% >" >
<%=names[l][0]% >
</option >
<%
} }
% > 谢谢楼上的,还有如上用红色的问题
自己太粗心了
for (int l=0;l <unitNum;l++) { if (sUnitId == names[l][1]) { ==>sUnitId.equals(names[l][1]);
% >
<option selected value=" <%=names[l][1]% >" >
<%=names[l][0]% >
</option >
<%
} else {
% >
<option value==" <%=names[l][1]% >" >
<%=names[l][0]% >
</option >
<%
} }
% > 谢谢楼上的,还有如上用红色的问题,问题已经解决了。
自己太粗心了
String ordertype=func.format(request.getParameter("ordertype"));
if (ordertype.equals("error")||ordertype==null){
ordertype="";
}
%> <form name="form2" method="post" action="">
<tr bgcolor="#FFFFFF">
<td width="217" height="25" align="right">部门类别:</td>
<td height="25" colspan="3">
<SELECT name="ordertype" size="1" onchange="javascript:form.submit()" dataType="Require" msg="请选择部门类别">
<OPTION selected value="">-=请选择=-</OPTION>
<%
String sqlt="select * from depttype order by deptnum asc";
rs=st.executeQuery(sqlt);
while(rs.next())
{%>
<OPTION value="<%=rs.getString("id")%>"><%=rs.getString("deptname")%></OPTION>
<%}%>
</SELECT>
<script>
<%if(ordertype!=null){%>
document.all("ordertype").value="<%=ordertype%>";
<%}%>
</script>
</td>
</tr>
</form>
////////////////////////////////从我程序中直接摘取的,没有怎么改动,应该能看懂吧!!!!