<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%><jsp:include flush="true" page="/waiting.jsp" />
<html> <head>
<title>用户名分配</title>
<link href="<%=request.getContextPath()%>/css/style.css" type="text/css" rel="stylesheet" />
<SCRIPT language="javascript"></SCRIPT> </head>
<body bgcolor="lightblue"> <html:form action="/userAction">
<TABLE width="90%" align="center" cellpadding="0" cellspacing="0" border="0" class="input">
<div id="div1">
<table id="t1" width="100%" align="center" cellpadding="1" cellspacing="1" border="1">
        <tr align="center">
  <td colspan="9">
<FONT size="8">用户名查看</FONT>
          </td>
</tr>
<tr>
    <td>科目</td>
    <td><input name="lessonname" autocomplete="off" style="width:80px;"></td>

            <td>题目</td>
    <td><input name="rolename" autocomplete="off" style="width:80px;"></td>     <td>年级</td>
    <td><input name="belonggradeid" autocomplete="off" style="width:80px;"></td>

            <td>用户数量</td>
    <td><input id="num" autocomplete="off" style="width:80px;"> </td>


<TD width="10%" align="left">
<html:submit property="next" value="确   定" onclick="showWaitDialog()" />
</TD>

</tr>
        </table>
</div>

<div id=div2>
<table id="t2" border="1" width="100%">
<logic:present property="ROWS" name="userActionForm">
<logic:iterate id="item" property="ROWS" name="userActionForm">
<tr align="center">
    <th>科目</th>
    <th>服务器地址</th>
    <th>用户名</th>
    <th>密码</th>
    <th>题目</th>
    <th>示例</th>

</tr>
<tr align="center">
<td><bean:write property="科目" name="item" /></td>
<td class=bg align="center">
<%=request.getLocalAddr()%>
</td>
<td><bean:write property="用户名" name="item" /></td>
<td><bean:write property="密码" name="item" /></td>
<td><bean:write property="题目" name="item" /></td> </tr> </logic:iterate>
</logic:present> </table>
</div></TABLE>
</html:form>
</body>
</html>
-----------------------------
我想实现2个功能
1>在用户数量文本框输入几就显示出来几条数据,JS实现
2>当点击提交之后,第一个div隐藏,只显示第二个请注意按钮属性是submit而不是button,button我会,这个submit怎么也搞不出来

解决方案 »

  1.   

    不是一样的吗.在form里面onsubmit事件,完事了return true就可以了啊
      

  2.   

    submit按钮除了调用onclick事件
    还会调用form的onsubmit事件
    在onsubmit事件里可以决定返回true还是false
    这个代表form是否会被提交
      

  3.   

    给你的例子<form id="form1" onsubmit="return checkForm()">
    <input type="submit" onclick="clickSubmit()">
    </form>
    <script>
    function checkForm() {
    alert("check");
    return false; //false表示form不提交
    }
    function clickSubmit() {
    alert("click");
    }
    </script>
      

  4.   

    <html:submit property="next" value="确   定" onclick="return showWaitDialog()" />你的showWaitDialog方法返回值改成true or false
    当点击提交之后,第一个div隐藏,只显示第二个 document.getElementById("div1").style.display="block";
    1>在用户数量文本框输入几就显示出来几条数据,JS实现 
    这个不太明白你的意思
      

  5.   

    同意楼上的观点~
    问题1:
    通过click事件进行判断~判断用户是否有输入用户数量以及类型~如果有误就返回一个false~无误则提交~通过获取页面提交的用户数量就可以查询数据库并加载相应条数的数据了~
    问题2:
    lz你可以通过设置一个标志来确定是否提交~如果提交了~就把标志里的值改变~在页面加上判断~通过判断根据你所设置的标志来确定显不显示div1~
      

  6.   

    document.getElementById("div1").style.display="none";
    document.getElementById("div2").style.display="";