日期:2014-05-17  浏览次数:20685 次

javaweb动态生成投票选项的问题
index.jsp:
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>动态生成投票选项</title>
<script language="javascript" type="">
  function Mycheck(){
  if(form2.name.value=="")
  { 
  alert("请输入投票信息!");
  return false;
  }
  form2.submit();
  }
</script>
</head>
<body>
<table width="570" height="275" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
  <td align="right" background="bg.gif">
  <table width="80%" height="104" border="0" cellpadding="0" cellspacing="0">
  <tr>
  <td width="10%">&nbsp;</td>
  <td width="79%" valign="top">
  <%if(session.getAttribute("list")!=null){%>
  <table width="315" border="0" cellpadding="0" cellspacing="0">
  <form name="form1" method="post" action="dealwith.jsp?action=insertAll">  
  <tr>
  <td height="25" colspan="2"><b>您最喜爱的图书评选:</b></td>
  </tr>
  <%
  List list=(List)session.getAttribute("list");
  String allName="";
  for(int i=0;i<list.size();i++){
  allName=(String)list.get(i);
  %>
  <tr>
  <td width="230" height="25">选项名称: </td>
  <td width="85" height="25">
  <input type="text" name="allName" value="<%=allName%>">
  </td>
  </tr>
  <%}%>
  <tr>
  <td height="25" colspan="2"><input type="submit" name="Submit" value="保存投票信息"></td>
  </tr> </form>
  </table>
  <%}%>
<table width="315" border="0" cellpadding="0" cellspacing="0">
  <form name="form2" method="post" action="dealwith.jsp?action=insertOne" onsubmit="return Mycheck()">
  <tr>
  <td height="25"><b>请输入投票选项,并单击【添加投票选项】按钮!</b></td>
  </tr>
  <tr>
  <td height="25"><input type="text" name="name"></td>
  </tr>
  <tr>
  <td height="25"> <input type="submit" name="Submit2" value="添加投票选项" >
  </td>
  </tr>
  </form>
</table>