<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css" href="<%=path%>/css/table.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/Tips.css"/>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function back(){
window.history.back(-1);
}
function query(){
window.open("<%=path%>/staff/initStaff.action","_self");
}
</script>
<title>人员信息</title>
</head>
<body>
<s:form id="from1" name="from1" action="save" method="post" namespace="/staff">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6%" height="19" valign="bottom"><div align="center"><img src="<%=path%>/images/tb.gif" width="14" height="14" /></div></td>
<td width="94%" valign="bottom"><span class="STYLE1">添加人员:</span></td>
</tr>
</table></td>
<td>
<div align="right">
<span class="STYLE1">
<input type="button" class="btn" value="查询" onclick="query();">
<input type="button" class="btn" value="返回" onclick="back();">
<span class="STYLE1"> </span>
</div>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
单位:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:property value="depart.name"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
客户名称:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:property value="userName"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
身份证:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:property value="cardIdentity"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
客户住址:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="null == address || '' == address">
暂无数据
</s:if>
<s:property value="address"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
客户编号:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="null == userIdentifier || '' == userIdentifier">
暂无数据
</s:if>
<s:property value="userIdentifier"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
性别:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="0 == sex">男</s:if>
<s:if test="1 == sex">女</s:if>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
备注:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="null == userIdentifier || '' == userIdentifier">
暂无数据
</s:if>
<s:property value="re"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</s:form>
</body>
</html>
这是我的页面,各位高手看看怎么能拿到我的迭代标签里面的list,好像js无法解析迭代标签,用document.getElementById("")也拿不到
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css" href="<%=path%>/css/table.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/Tips.css"/>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function back(){
window.history.back(-1);
}
function query(){
window.open("<%=path%>/staff/initStaff.action","_self");
}
</script>
<title>人员信息</title>
</head>
<body>
<s:form id="from1" name="from1" action="save" method="post" namespace="/staff">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6%" height="19" valign="bottom"><div align="center"><img src="<%=path%>/images/tb.gif" width="14" height="14" /></div></td>
<td width="94%" valign="bottom"><span class="STYLE1">添加人员:</span></td>
</tr>
</table></td>
<td>
<div align="right">
<span class="STYLE1">
<input type="button" class="btn" value="查询" onclick="query();">
<input type="button" class="btn" value="返回" onclick="back();">
<span class="STYLE1"> </span>
</div>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
单位:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:property value="depart.name"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
客户名称:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:property value="userName"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
身份证:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:property value="cardIdentity"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
客户住址:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="null == address || '' == address">
暂无数据
</s:if>
<s:property value="address"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
客户编号:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="null == userIdentifier || '' == userIdentifier">
暂无数据
</s:if>
<s:property value="userIdentifier"/>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
性别:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="0 == sex">男</s:if>
<s:if test="1 == sex">女</s:if>
</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
备注:
</td>
<td height="20" bgcolor="#FFFFFF" align="center" width="50%">
<s:if test="null == userIdentifier || '' == userIdentifier">
暂无数据
</s:if>
<s:property value="re"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</s:form>
</body>
</html>
这是我的页面,各位高手看看怎么能拿到我的迭代标签里面的list,好像js无法解析迭代标签,用document.getElementById("")也拿不到
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
%>
<html>
<head>
<title>客户信息查询</title>
</head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
<link rel="stylesheet" type="text/css" href="<%=path%>/css/table.css"/>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.4.min.js"></script>
<script language="JavaScript" type="text/javascript" src="<%=path%>/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function back(){
window.history.back(-1);
}
function sub(obj){
document.getElementById("currentPage").value = obj;
document.getElementById("from1").submit();
}
function info(obj){
var str = "<%=path%>/staff/getInfo.action?id=" + obj;
window.open(str,"_self");
}
function update(obj){
var str = "<%=path%>/staff/get.action?id=" + obj;
window.open(str,"_self");
}
function del(obj){
if(confirm("确定删除吗?")){
$.ajax( {
url :"<%=path%>/staff/ajaxDel.action?",
type : "post",
data : "id=" + obj,
success : functionBack
});
}
}
//del回调函数
function functionBack(json){
if("success" == json){
document.getElementById("from1").submit();
}else{
alert("删除失败,请稍后再试!");
}
}
function sel(){
var userName=document.getElementById("userName").value;
var cardIdentity=document.getElementById("cardIdentity").value;
var departID=document.getElementById("departID").value;
var appointTime=document.getElementById("appointTime").value;
var startTime=document.getElementById("startTime").value;
var endTime=document.getElementById("endTime").value;
if(userName==""&&cardIdentity==""&&departID==0&&appointTime==""&&startTime==""&&endTime==""){
alert("请您输入查询信息");
return false;
}
var i=0;
if(userName!=""){
i++;
}
if(cardIdentity!=""){
i++;
}
if(departID!=0){
i++;
}
if(appointTime!=""){
i++;
}
if(""!=appointTime&&endTime!=""){
i++;
}
if(i>1){
alert("对不起,您每次只能选择一种查询方式");
return false;
}
else{
document.getElementById("from1").submit();
}
}
</script>
<body>
<s:form id="from1" name="from1" action="queryStaff.action" namespace="/staff" method="post">
<s:hidden name="currentPage"></s:hidden>
<s:hidden name="allRow"></s:hidden>
<s:hidden name="list"></s:hidden>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="6%" height="19" valign="bottom"><div align="center"><img src="<%=path%>/images/tb.gif" width="14" height="14" /></div></td>
<td width="94%" valign="bottom"><span class="STYLE1">客户信息查询:</span></td>
<td>
<input align="right" type="button" class="btn" name="query" value="查询" onclick="sel();"/>
</td>
</tr>
</table>
</td>
</tr></table></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
<tr>
<td width="10%" height="20" bgcolor="d3eaef" class="STYLE10" colspan="1" align="center">
基本查询
</td>
<td width="70%" height="20" bgcolor="d3eaef" class="STYLE10" colspan="5">
姓 名:<s:textfield name="userName" id="userName"></s:textfield>
身份证:<s:textfield name="cardIdentity"></s:textfield>
单 位:
<select name="departID" style="width:155px" name="departID">
<s:if test="#session.UserInfo.flag == 2 || #session.UserInfo.flag == 3">
<option value="<s:property value="#session.UserInfo.depart.id"/>"><s:property value="#session.UserInfo.depart.name"/></option>
</s:if><s:else>
<option value="0">选择单位</option>
<s:iterator value="listDepart" var="st" >
<option value="<s:property value="id"/>" <s:if test="departID == id">selected="selected"</s:if>><s:property value="name"/></option>
</s:iterator>
</s:else>
</select>
</td>
</tr>
<tr>
<td width="10%" height="20" bgcolor="d3eaef" class="STYLE10" colspan="1" align="center">
时间查询
</td>
<td width="30%" height="20" bgcolor="d3eaef" class="STYLE10" colspan="5">
指定日期:
<input type="text" name="appointTime" id="appointTime" value="<s:property value="appointTime"/>" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
开始日期:
<input type="text" name="startTime" id="startTime" value="<s:property value="startTime"/>" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
结束日期:
<input type="text" name="endTime" id="endTime" value="<s:property value="endTime"/>" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>
</td>
</tr>
<tr>
<td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">用户名</span></div></td>
<td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">身份证</span></div></td>
<td width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">单位</span></div></td>
<td width="24%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">注册时间</span></div></td>
<td width="20%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">操作</span></div></td>
</tr>
<s:iterator value="list" var="st">
<tr>
<td width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center">
<span class="STYLE10"><s:property value="#st[1]"/></span></div>
</td>
<td width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center">
<span class="STYLE10"><s:property value="#st[2]"/></span></div>
</td>
<td width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center">
<span class="STYLE10">
<s:if test="null == #st[6]">
暂无数据
</s:if><s:else>
<s:property value="#st[6]"/>
</s:else>
</span></div>
</td>
<td width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center">
<span class="STYLE10"><s:date name="#st[4]" format="yyyy年MM月dd号"/></span></div>
</td>
<td width="16%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">
<s:if test="#session.UserInfo.flag == 0 || #session.UserInfo.flag == 1 ||
#session.UserInfo.flag == 2 && #session.UserInfo.depart.id == #st[5]">
<a href="javascript:;" onclick="info(<s:property value="#st[0]"/>); return false;">查看</a>
<a href="javascript:;" onclick="update(<s:property value="#st[0]"/>); return false;">修改</a>
</s:if>
<s:if test="#session.UserInfo.flag == 0 || #session.UserInfo.flag == 1">
<a href="javascript:;" onclick="del(<s:property value="#st[0]"/>); return false;">删除</a>
</s:if>
</span></div>
</td>
</tr>
</s:iterator> <s:if test="null!=list">
<tr>
<td colspan="5" align="center">
共<s:property value="allRow"/>条
共<s:property value="totalPage"/>页
当前第<s:property value="currentPage"/>页
<s:if test="currentPage == 1">第一页 上一页</s:if>
<s:else>
<a href="" onclick="sub(1); return false;">第一页</a>
<a href="" onclick="sub(<s:property value="currentPage-1"/>); return false;">上一页</a>
<%--
<a href="<%=path%>/staff/queryStaff.action?currentPage=1">第一页</a>
<a href="<%=path%>/staff/queryStaff.action?currentPage=<s:property value="currentPage-1"/>">上一页</a>
--%>
</s:else>
<s:if test="currentPage != totalPage">
<a href="javascript:;" onclick="sub(<s:property value="currentPage+1"/>); return false;">下一页</a>
<a href="javascript:;" onclick="sub(<s:property value="totalPage"/>); return false;">最后一页</a>
<%--
<a href="<%=path%>/staff/queryStaff.action?currentPage=<s:property value="currentPage+1"/>">下一页</a>
<a href="<%=path%>/staff/queryStaff.action?currentPage=<s:property value="totalPage"/>">最后一页</a>
--%>
</s:if>
<s:else>
下一页 最后一页
</s:else>
</td>
</tr>
</s:if>
</table>
</td>
</tr>
</table>
</s:form> </body>
</html>
如何获得 <s:iterator value="list" var="st">中的list,用js的docuement.getElementById("")好像无法获得
如何获得 <s:iterator value="list" var="st">中的list,用js的docuement.getElementById("")好像无法获得
<s:iterator 是后台jsp中的代码,相当于在这个页面中标识下,这里需要for循环进行处理,然后在自定义标签中关联的java代码中进行循环输出。
你前台看到的时候struts处理过的能被浏览器识别的标签,
别异想天开的通过js获取里边的list了。
<input type="checkbox" name="checkboxs" value=""/>
再可以用docuement.getElementsByName()得到一个集合
var values=docuement.getElementsByName();注意getElementsByName()中Elements中s还有把标签input隐藏
<s:property value="s.index">
</s:iterator>
可以利用 <s:iterator>的status属性来获得当前的顺序号码。0,1,2,3.....