js onclick()事件 增加div 和内部的 form 大大门 我好晕

李小萌是只喵 2019-08-13 05:35:24
<%@LANGUAGE="VBSCRIPT" %>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
工单
</title>
<style>
#workdo {
margin:auto;
margin-top:50px;
padding:3px;
background-color:#FFF;
width:90%;
height:95%;
}
</style>
</head>
<body>
<div>这里是工单操作说明区</div>
<hr>
<hr>
<div id="workdo">
<li>工单</li>
<li>工单项目</li>
<form action="addwork.asp" name="addwork" id="form1" method="post">
<li><select style="width:50%;"name="select" size="1" multiple="multiple" id="select">
<option>工单项目一</option>
<option>工单项目二</option>
<option>工单项目三</option>

</select></li>
<li>溶液材料</li>
<li><select style="width:50%;"name="select" size="1" multiple="multiple" id="select">
<option>乳化剂</option>
<option>金属表面活性剂</option>

</select></li>
<li>使用数量</li>
<li><select style="width:50%;"name="select" size="1" multiple="multiple" id="select">
<option>一组</option>
<option>两组</option>
<option>三组</option>
</select></li>
<li>操作方式</li>
<li> <select style="width:50%;"name="select" size="1" multiple="multiple" id="select">
<option>拖挂</option>
<option>滞留</option>
<option>扣板</option>

</select></li>
<li>配送方式</li>
<li> <select style="width:50%;"name="select" size="1" multiple="multiple" id="select">
<option>物流</option>
<option>快递</option>
<option>自提</option>
</select></li>
</form>
</div>
function Addiv(){
document.write("<div id=\"workdo\">");
document.write("<li>工单<\/li>");
document.write("<li>工单项目<\/li>");
document.write("<form action=\"addwork.asp\" name=\"addwork\" id=\"form1\" method=\"post\">");
document.write("<li><select style=\"width:50%;\"name=\"select\" size=\"1\" multiple=\"multiple\" id=\"select\">");
document.write(" <option>Jorder<\/option>");
document.write(" <option>DDboss<\/option>");
document.write("");
document.write(" <\/select><\/li>");
document.write("<li>溶液材料<\/li>");
document.write("<li><select style=\"width:50%;\"name=\"select\" size=\"1\" multiple=\"multiple\" id=\"select\">");
document.write(" <option>乳化剂<\/option>");
document.write(" <option>金属表面活性剂<\/option>");
document.write("");
document.write(" <\/select><\/li>");
document.write("<li>使用数量<\/li>");
document.write("<li><select style=\"width:50%;\"name=\"select\" size=\"1\" multiple=\"multiple\" id=\"select\">");
document.write(" <option>一组<\/option>");
document.write(" <option>两组<\/option>");
document.write(" <option>三组<\/option>");
document.write(" <\/select><\/li>");
document.write("<li>操作方式<\/li>");
document.write("<li> <select style=\"width:50%;\"name=\"select\" size=\"1\" multiple=\"multiple\" id=\"select\">");
document.write(" <option>拖挂<\/option>");
document.write(" <option>滞留<\/option>");
document.write(" <option>扣板<\/option>");
document.write("");
document.write(" <\/select><\/li>");
document.write("<li>配送方式<\/li>");
document.write("<li> <select style=\"width:50%;\"name=\"select\" size=\"1\" multiple=\"multiple\" id=\"select\">");
document.write(" <option>物流<\/option>");
document.write(" <option>快递<\/option>");
document.write(" <option>自提<\/option>");
document.write(" <\/select><\/li>");
document.write("<\/form>");
document.write("<\/div>");
}
<div>

<input style="font-size:4vw;"type="button" value="添加一组工单" onclick="Addiv();" /></div>
</div>
</body>
</html>


------------------------
ASP+access的一个小小工单系统
需要同一页面能增加工单,就是点一下添加一组工单 然后会增加 id="workdo"里面所有的内容,并且form1 自动变成 form2 form3
弄不好了,现在这样点击onclick 结果就是刷掉其他的内容 连style都没了 就剩下 workdo 里面的内容了,请问大大们 这要怎么处理好啊,我是小白菜
...全文
152 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
李小萌是只喵 2019-08-13
  • 打赏
  • 举报
回复
引用 4 楼 文盲老顾 的回复:
function Addiv(){
var el = document.getElementById('workdo');
var nel = document.createElement('div');
nel.innerHTML=el.innerHTML;
document.documentElement.appendChild(nel);
}


我直接复制一份到 documentElement上了,位置没弄

如果有需要你可以自己弄到指定位置,百度 js appendChild,js insertBefore,用法差不多


引用 4 楼 文盲老顾 的回复:
function Addiv(){
var el = document.getElementById('workdo');
var nel = document.createElement('div');
nel.innerHTML=el.innerHTML;
document.documentElement.appendChild(nel);
}


我直接复制一份到 documentElement上了,位置没弄

如果有需要你可以自己弄到指定位置,百度 js appendChild,js insertBefore,用法差不多


引用 4 楼 文盲老顾 的回复:
function Addiv(){
var el = document.getElementById('workdo');
var nel = document.createElement('div');
nel.innerHTML=el.innerHTML;
document.documentElement.appendChild(nel);
}


我直接复制一份到 documentElement上了,位置没弄

如果有需要你可以自己弄到指定位置,百度 js appendChild,js insertBefore,用法差不多


引用 4 楼 文盲老顾 的回复:
function Addiv(){
var el = document.getElementById('workdo');
var nel = document.createElement('div');
nel.innerHTML=el.innerHTML;
document.documentElement.appendChild(nel);
}


我直接复制一份到 documentElement上了,位置没弄

如果有需要你可以自己弄到指定位置,百度 js appendChild,js insertBefore,用法差不多


引用 4 楼 文盲老顾 的回复:
function Addiv(){
var el = document.getElementById('workdo');
var nel = document.createElement('div');
nel.innerHTML=el.innerHTML;
document.documentElement.appendChild(nel);
}


我直接复制一份到 documentElement上了,位置没弄

如果有需要你可以自己弄到指定位置,百度 js appendChild,js insertBefore,用法差不多


ore,用法差不多[/quote]
现在增加了 可是head 和 body里的其他东西都没有了 form1不会自动增加哇
文盲老顾 2019-08-13
  • 打赏
  • 举报
回复
function Addiv(){
    var el = document.getElementById('workdo');
	var nel = document.createElement('div');
	nel.innerHTML=el.innerHTML;
	document.documentElement.appendChild(nel);
}
我直接复制一份到 documentElement上了,位置没弄 如果有需要你可以自己弄到指定位置,百度 js appendChild,js insertBefore,用法差不多
李小萌是只喵 2019-08-13
  • 打赏
  • 举报
回复
引用 2 楼 文盲老顾 的回复:
页面加载完成后,不要再使用 document.write,使用 jquery的话,直接 $('').appendTo,原生js的话,document.createElement,然后append


大大,我用的是原生的js 可是append 不会啊 能帮我改下不哇 谢谢哇
文盲老顾 2019-08-13
  • 打赏
  • 举报
回复
页面加载完成后,不要再使用 document.write,使用 jquery的话,直接 $('').appendTo,原生js的话,document.createElement,然后append
李小萌是只喵 2019-08-13
  • 打赏
  • 举报
回复
有人来救我么

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧