<%@page contentType="text/html;charset=UTF-8" %>
<!-- 导入struts2标签库 -->
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page import="java.util.Map" %>
<%
String context =request.getContextPath();
%>
<html>
<head>
<script type="text/javascript" src="<%=context%>/javascript/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<%=context%>/javascript/util.js"></script>
</head>
<body >
<%
String keyAsString =(String) session.getAttribute("keyAsString");
String valueAsString =(String) session.getAttribute("valueAsString");
out.print(keyAsString);
%>
<br>
<%
out.print(valueAsString);
%>
<form >
<%@ include file="/hidp/autocreateform/applyForm.jsp" %>
<script>
var keyAsString = "<%=keyAsString%>"; //定义一个变量存储后台传过来的Map对象key的值 // 注意:表达式要加上引号
var valueAsString = "<%=valueAsString%>"; //定义一个变量存储后台传过来的Map对象value的值 // 注意:表达式要加上引号
var mapKeyAsArray = keyAsString.split(","); //由字符串生成存储map中每一个key的数组
var mapValueAsArray = valueAsString.split(","); //由字符串生成存储map中每一个value的数组
//var inputElementAsArray = $(":input"); //注意() {}
var inputElementAsArray = $(":input"); //注意() {}
var inputNameAttributeAsArray = new Array(); //创建一个数组用来保存页面中所有input标签的name的属性值
//遍历所有input标签中的name属性并将其属性值存放到一个新的数组中
for(var i=0; i<inputElementAsArray.length-1; i++)
{
inputNameAttributeAsArray[i] = $(inputElementAsArray[i]).attr("name"); //注意:加上$符号
}
for(var i=0; i<inputNameAttributeAsArray.length; i++)
{
for(var j=0; j<mapKeyAsArray.length; j++)
{
if(inputNameAttributeAsArray[i] == mapKeyAsArray[j])
inputNameAttributeAsArray[i] = mapValueAsArray[j];
}
}
for(var i=0; i<inputNameAttributeAsArray.length-1; i++)
{
var inputIndex = $(":input").get(i);
$(inputIndex).attr("value",inputNameAttributeAsArray[i]);
$(inputIndex).attr("disabled", "disabled");
$(inputIndex).attr("type", "hidden")// type="hidden"
}
var submit = $(":submit");
for(var i=0; i<submit.length; i++)
{
//$(submit[i]).attr("type", "hidden");
}
var reset = $(":reset");
var button = $(":button");
</script>
</form>
</body>
</html>