运用JS判断代码可以参考学习
JAVAScript代码加CSS和HTML
<%--
Created by IntelliJ IDEA.
User: zengxiangcai
Date: 2018/6/27
Time: 11:43
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>大批量生成数组数据</title>
<style>
.BB{
width: 400px;
height: 300px;
position: absolute;
left:400px ;
top: 1px;
margin-left: 50px;
/*margin-top: -150px;*/
/**/
}
.EE{
width: 400px;
height: 300px;
position: absolute;
left:250px ;
top: 370px;
margin-left: 50px;
/*margin-top: -150px;*/
/**/
}
.FF{
width: 400px;
height: 300px;
position: absolute;
left:550px ;
top: 370px;
margin-left: 50px;
/*margin-top: -150px;*/
/**/
}
.GG{
width: 400px;
height: 300px;
position: absolute;
left:850px;
top: 10px;
margin-left: 50px;
/*margin-top: -150px;*/
/**/
}
.HH{
width: 400px;
height: 300px;
position: absolute;
left:850px;
top: 370px;
margin-left: 50px;
/*margin-top: -150px;*/
/**/
}
</style>
<script type="text/javascript">
var myArr=new Array();
var start;
var end;
function newArray(){
var patrn = /^[0-9]*$/;
var qz = "COO";//前缀
var numStart=document.getElementById("textst").value; //数量起
var numEnd=document.getElementById("textEnd").value; //数量止
start = numStart;
end = numEnd;
var numberCopies=document.getElementById("numberCopies").value; //份数
if(!patrn.test(numStart) && !patrn.test(numEnd) && !patrn.test(numberCopies)){
alert("请输入合法的数字!!!");
return;
}
var dataNum = numEnd - numStart + 1;
if(dataNum<0){
alert("请输入准确的起止数字!!!");
}
var z=0;
for(i = 0; i < dataNum ; i++) {
for(j = 0; j < numberCopies ; j++) {
myArr[z] = qz + numStart;
z++ ;
}
numStart++;
}
show();
repeat();
dataNum();
}
function show(){
var txt="";
for(var n=0;n<myArr.length;n++){
txt = txt + myArr[n] + " ";
}
document.getElementById("textAll").value=txt;
document.getElementById("textBll").value=txt;
}
//删除数据
function deleted() {
var data = myArr;
var arr = document.getElementById("arr").value;
var m = arr.split(",");
var value="";
var sumCll=0;
var sumEll=0;
var er="";
var index;
var patrn = /^COO+[0-9]*$/;
console.log(arr);
if(arr){
for(var i=0;i<m.length;i++){
if(patrn.test(m[i])==false){
er+="错误条码:"+m[i]+"\r\n";
sumEll+=1;
}else{
index = data.indexOf(m[i]);
console.log(index);
if (index != -1) {
data.splice(index,1);
console.log(data);
myArr = data;
show();
}else{
value += "条码:"+m[i]+"不存在\r\n";
sumCll+=1;
}
}
repeat();
document.getElementById("textCll").value=value;
document.getElementById("textEll").innerHTML=er;
re("not",sumCll);
re("error",sumEll);
}
}
function newArray() {
var patrn = /^[0-9]*$/;
var qz = "COO";//前缀
var numStart = document.getElementById("textst").value; //数量起
var numEnd = document.getElementById("textEnd").value; //数量止
var numberCopies = document.getElementById("numberCopies").value; //份数
if (!patrn.test(numStart>numEnd) && !patrn.test(numberCopies<0)) {
document.getElementById("textCll").value=myArr;
}
var dataNum = numEnd - numStart + 1;
if (numberCopies < 0) {
var newData = data.replace(arr, "");
document.getElementById("textCll").value=myArr;
document.getElementById("textEll").value=myArr;
}
}
}
function repeat(){
var s = start;
var count = -1;
var qz = "COO";
var str;
var sum=0;
var my="";
for(var i=0;i<=end-start;i++){
str = qz + s;
for(var j=0;j<myArr.length;j++){
if(myArr[j]==str){
count+=1;
}
}
sum =sum +count;
if(count!=-1)
my = my + str+" 重复数:"+count+"\r\n";
count=-1;
s++;
}
document.getElementById("textDll").value = my;
re("repeat",sum);
}
function re(name,sum){
var re = document.getElementsByClassName(name);
for(var i=0;i<re.length;i++){
re[i].innerHTML=sum;
}
}
</script>
<!--显示时间-->
<script language="javascript">
var t = null;
t = setTimeout(time,1000);//开始执行
function time()
{
clearTimeout(t);//清除定时器
dt = new Date();
var h=dt.getHours();
var m=dt.getMinutes();
var s=dt.getSeconds();
document.getElementById("timeShow").innerHTML = h+"时"+m+"分"+s+"秒";
t = setTimeout(time,1000); //设定定时器,循环执行
}
</script>
</head>
<body>
<form action="acions">
<div class="cc">
<div class="aa" >
<h6>根据条码规则生成原始数据( <span class=""></span> )</h6>
<textarea style="width:300px;height:150px; overflow:scroll; border:1px solid;" id="textAll" >
</textarea></br>
<input type="text" id="textst" placeholder="数量起"/></br>
<input type="text" id="textEnd" placeholder="数量止"/></br>
<input type="text" id="numberCopies" placeholder="份数" /></br>
<input type="button" onclick="newArray()" value="数据生成" /></br>
<input type="text" id="arr" placeholder="输入已有的数据" /></br>
<input type="button" onclick="deleted()" value="删除数据" /></br>
</div>
<div class="BB">
<h6>待检测条码( <span class=""></span> )</h6>
<textarea style="width:300px; height:150px; overflow:scroll; border:1px solid;" id="textBll" ></textarea></br>
<input type="text" id="text" placeholder="输入测试数据"/></br>
<input type="button" onclick="newArray()" value="测试数据" /></br>
</div>
<div class="DD">
<h6>重复条码( <span class = "not">0</span> )</h6>
<textarea style="width:200px; height:250px; overflow:scroll; border:1px solid;" id="textCll" ></textarea></br>
</div>
<div class="EE">
<h6>重复存在条码( <span class = "repeat">0</span> )</h6>
<textarea style="width:200px; height:250px; overflow:scroll; border:1px solid;" id="textDll" ></textarea></br>
</div>
<div class="FF">
<h6>错误条码( <span class = "error">0</span> )</h6>
<textarea style="width:200px; height:250px; overflow:scroll; border:1px solid;" id="textEll" ></textarea></br>
</div>
<div class="HH">
<h6>遗漏条码( <span class = "error">0</span> )</h6>
<textarea style="width:200px; height:250px; overflow:scroll; border:1px solid;" id="textFll" ></textarea></br>
</div>
<div class="GG">
<h3 style="size: auto">条码检测报告</h3>
<h6>----------------------------------</h6>
<h5>检测时间: <label id="timeShow"></label></h5>
<h5>检测人:***    </h5>
<h5>重复条码:( <span class = "not">0</span> )</h5>
<h5>重复条码:( <span class = "repeat">0</span> )</h5>
<h5>错误条码:( <span class = "error">0</span> )</h5>
<h5>遗漏条码:(<span class=""></span>)</h5>
<input type="button" onclick="aaaa()" value="提交" /></br>
</div>
</div>
</form>
</body>
</html>
欢迎你的观看,一起学习代码。