这一个,你们看看行吗? <%@ page contentType="text/html;charset=gb2312"%>
<HTML>
<head><title>职员报销登记表</title>
<head>
<script>
function changePayStyle(type){
if(type=='1'){
pay1.style.display="block";
pay2.style.display="block";
pay3.style.display="none";
pay4.style.display="none";
pay5.style.display="none";
pay6.style.display="none";
}else if(type=='2'){
pay1.style.display="none";
pay2.style.display="none";
pay3.style..display="block";
pay4.style.display="block";
pay5.style.display="none";
pay6.style.display="none";
}
else if(type=='3'){
pay1.style.display="none";
pay2.style.display="none";
pay3.style.display="none";
pay4.style.display="none";
pay5.style.display="block";
pay6.style.display="block";
}
}
function doAdd(){
var addText = document.getElementById('addText').value;
if(addText.length==0){
alert("输入的内容不能为空。");
}
document.getElementById("add&del_tip").firstChild.nodeValue ="输入你要添加的费用科目:";
var feeNode = document.getElementById('feeType');
var optionText = document.createTextNode(addText);
var NewElementNode = null;
try{
//for ie
NewElementNode = document.createElement("<input type= 'radio' name= 'mp' value='"+addText+"'>");
}catch(err){
NewElementNode = document.createElement("input");
NewElementNode.setAttribute("type","radio");
NewElementNode.setAttribute("name","mp");
NewElementNode.setAttribute("value",addText);
}
feeNode.appendChild(NewElementNode);
feeNode.appendChild(optionText);
}function del(){
var addText = document.getElementById('addText').value;
if(addText.length==0){
alert("输入的内容不能为空。");
}
document.getElementById("add&del_tip").firstChild.nodeValue ="输入你要删除的费用科目:";
var feeNode = document.getElementById('feeType');
var input_feeNodes = feeNode.getElementsByTagName('input');
for(var i=0;i<input_feeNodes.length;i++){
//alert(input_feeNodes[i].value+" "+addText)
if(input_feeNodes[i].value==addText){
feeNode.removeChild(input_feeNodes[i].nextSibling);
feeNode.removeChild(input_feeNodes[i]);
return;
}
}
alert("不存在你要删除的费用科目。") ;
}</script>
<body>
<p align="center"><br><br>
<font size=64pt>职员报销登记表</font>
</p>
<div align="center">
<div id="add">
<span id="add&del_tip">输入你要添加的费用科目:</span>
<br/>
<input type="text" size="30" id="addText"/>
<button onclick="doAdd();">添加</button>
<button onclick="del();">删除</button>
<br/>
<div>金 额 <input type="text" name="jine">
报 销 人 <input type="text" name="people"><br><br> <br>
部 门 <input type="text" name="dpt">
归 属 <input type="text" name="belong" ><br><br><br>
财 务 月 份 <select name="month" style="width"100" size="1">
<option value="1" selected > 1 </option>
<option value="2" > 2</option>
<option value="3" > 3 </option>
<option value="4" > 4 </option>
<option value="5" > 5</option>
<option value="6" > 6 </option>
<option value="7" > 7 </option>
<option value="8" > 8</option>
<option value="9" > 9</option>
<option value="10" > 10 </option>
<option value="11" > 11</option>
<option value="12" > 12 </option>
</select>
发 生 日 期 <input type="text" name="shij" >
<br><br><br>
费 用 类 型 <select name="type" style="width"200" size="1">
<option value="报销" selected>报销</option>
<option value="借款">借款</option>
</select>
项 目 类 型 <select name="pt" style="width"200" size="1">
<option value="发电" selected> 发电</option>
<option value="电网">电网</option>
</select><br><br><br>
项目归属<input type="text" name="pb"> </input>
<div id="feeType" style="display:inline">
费用科目
<input type="radio" name="mp" value="工程费用" checked onclick="changePayStyle('1')">工程费用</input>
<input type="radio" name="mp" value="日常费用" onclick="changePayStyle('2')">日常费用</input>
<input type="radio" name="mp" value="专项费用" onclick="changePayStyle('3')"> 专项费用</input>
</div>
</p>
<span style="margin-left:-400px;">科目明细:</span>
<ul style="list-style-type:none;" id="pay">
<li style="float:left;" id="pay1"> <input type="radio" name="pc" value="差旅费" checked>差旅费</input></li>
<li style="float:left;" id="pay2"> <input type="radio" name="pc" value="通讯费">通讯费</input></li>
<li style="float:left;display:none;" id="pay3"> <input type="radio" name="pcl" value="交通费">交通费</input></li>
<li style="float:left;display:none;" id="pay4"> <input type="radio" name="pc" value="办公费" >办公费</input></li>
<li style="float:left;display:none;" id="pay5"> <input type="radio" name="pc" value="会议费">会议费</input></li>
<li style="float:left;display:none;" id="pay6"> <input type="radio" name="pc" value="标书费" >标书费</input></li>
</ul>
<div style="clear:both;"></div>
<p align="center">
摘要<textarea NAME="sum" ROWS=6 COLS=64 >
</textarea>
<br><br><br>
</form>
</div>
</body></HTML>
<HTML>
<head><title>职员报销登记表</title>
<head>
<script>
function changePayStyle(type){
if(type=='1'){
pay1.style.display="block";
pay2.style.display="block";
pay3.style.display="none";
pay4.style.display="none";
pay5.style.display="none";
pay6.style.display="none";
}else if(type=='2'){
pay1.style.display="none";
pay2.style.display="none";
pay3.style..display="block";
pay4.style.display="block";
pay5.style.display="none";
pay6.style.display="none";
}
else if(type=='3'){
pay1.style.display="none";
pay2.style.display="none";
pay3.style.display="none";
pay4.style.display="none";
pay5.style.display="block";
pay6.style.display="block";
}
}
function doAdd(){
var addText = document.getElementById('addText').value;
if(addText.length==0){
alert("输入的内容不能为空。");
}
document.getElementById("add&del_tip").firstChild.nodeValue ="输入你要添加的费用科目:";
var feeNode = document.getElementById('feeType');
var optionText = document.createTextNode(addText);
var NewElementNode = null;
try{
//for ie
NewElementNode = document.createElement("<input type= 'radio' name= 'mp' value='"+addText+"'>");
}catch(err){
NewElementNode = document.createElement("input");
NewElementNode.setAttribute("type","radio");
NewElementNode.setAttribute("name","mp");
NewElementNode.setAttribute("value",addText);
}
feeNode.appendChild(NewElementNode);
feeNode.appendChild(optionText);
}function del(){
var addText = document.getElementById('addText').value;
if(addText.length==0){
alert("输入的内容不能为空。");
}
document.getElementById("add&del_tip").firstChild.nodeValue ="输入你要删除的费用科目:";
var feeNode = document.getElementById('feeType');
var input_feeNodes = feeNode.getElementsByTagName('input');
for(var i=0;i<input_feeNodes.length;i++){
//alert(input_feeNodes[i].value+" "+addText)
if(input_feeNodes[i].value==addText){
feeNode.removeChild(input_feeNodes[i].nextSibling);
feeNode.removeChild(input_feeNodes[i]);
return;
}
}
alert("不存在你要删除的费用科目。") ;
}</script>
<body>
<p align="center"><br><br>
<font size=64pt>职员报销登记表</font>
</p>
<div align="center">
<div id="add">
<span id="add&del_tip">输入你要添加的费用科目:</span>
<br/>
<input type="text" size="30" id="addText"/>
<button onclick="doAdd();">添加</button>
<button onclick="del();">删除</button>
<br/>
<div>金 额 <input type="text" name="jine">
报 销 人 <input type="text" name="people"><br><br> <br>
部 门 <input type="text" name="dpt">
归 属 <input type="text" name="belong" ><br><br><br>
财 务 月 份 <select name="month" style="width"100" size="1">
<option value="1" selected > 1 </option>
<option value="2" > 2</option>
<option value="3" > 3 </option>
<option value="4" > 4 </option>
<option value="5" > 5</option>
<option value="6" > 6 </option>
<option value="7" > 7 </option>
<option value="8" > 8</option>
<option value="9" > 9</option>
<option value="10" > 10 </option>
<option value="11" > 11</option>
<option value="12" > 12 </option>
</select>
发 生 日 期 <input type="text" name="shij" >
<br><br><br>
费 用 类 型 <select name="type" style="width"200" size="1">
<option value="报销" selected>报销</option>
<option value="借款">借款</option>
</select>
项 目 类 型 <select name="pt" style="width"200" size="1">
<option value="发电" selected> 发电</option>
<option value="电网">电网</option>
</select><br><br><br>
项目归属<input type="text" name="pb"> </input>
<div id="feeType" style="display:inline">
费用科目
<input type="radio" name="mp" value="工程费用" checked onclick="changePayStyle('1')">工程费用</input>
<input type="radio" name="mp" value="日常费用" onclick="changePayStyle('2')">日常费用</input>
<input type="radio" name="mp" value="专项费用" onclick="changePayStyle('3')"> 专项费用</input>
</div>
</p>
<span style="margin-left:-400px;">科目明细:</span>
<ul style="list-style-type:none;" id="pay">
<li style="float:left;" id="pay1"> <input type="radio" name="pc" value="差旅费" checked>差旅费</input></li>
<li style="float:left;" id="pay2"> <input type="radio" name="pc" value="通讯费">通讯费</input></li>
<li style="float:left;display:none;" id="pay3"> <input type="radio" name="pcl" value="交通费">交通费</input></li>
<li style="float:left;display:none;" id="pay4"> <input type="radio" name="pc" value="办公费" >办公费</input></li>
<li style="float:left;display:none;" id="pay5"> <input type="radio" name="pc" value="会议费">会议费</input></li>
<li style="float:left;display:none;" id="pay6"> <input type="radio" name="pc" value="标书费" >标书费</input></li>
</ul>
<div style="clear:both;"></div>
<p align="center">
摘要<textarea NAME="sum" ROWS=6 COLS=64 >
</textarea>
<br><br><br>
</form>
</div>
</body></HTML>
你上面不是会动态创建吗
var temp = document.createElement("input");
temp.setAttribute('type','text');
temp.setAttribute('name','aa');
feeNode.appendChild(temp);
其实要改的时候去人工改改页面就行了 反正这功能以后也不常用的
如果单就创建控件的话 好说 但是要涉及到提交时候的判断、request的入库以及对历史表单的读取呢 这要考虑的东西就多了