当前位置:网站首页>JS generates a specified number of characters according to some words
JS generates a specified number of characters according to some words
2022-04-23 04:42:00 【Move up】
List of articles
Copy the code to the text and change the suffix to html
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> generator </title>
</head>
<body>
<div id="menu" style="height:100%;width: 40%;float:left; ">
<textarea type="text" id="inputValue" style="font-size: 25px;height:1000px;width: 98%;float:left;border:1px solid black;margin: 3px;padding: 3px;"> Write the default value here </textarea>
</div>
<div id="menu" style="height:1000px;width: 10%;float:left;border:1px solid black;margin: 3px;padding: 30 3 3 3;text-align:center" >
Number of generated words :<input id="nubCount" type="text" value="3">
Number of generated :<input id="gCount" type="text" value="100">
<input type="button" onclick="genValue()" value=" Generate name ">
<input type="button" onclick="cleanGenValue()" value=" Empty and generate name ">
</div>
<div id="keys" style="font-size: 25px;height:10000px;width: 40%;float:left;border:1px solid black;margin: 3px;padding: 3px;text-align:center">
The location where the name is generated </div>
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
function genValue(){
var inputValue = $("#inputValue").val();
var nubCount = $("#nubCount").val();
var gCount = $("#gCount").val();
if(gCount === ''){
gCount = 100;
}
var arr = [];
if(inputValue ===''){
var defValue = " Heyuan Bofeng Yize ";
var arrdef = defValue.split("");
for(var j=0;j<gCount;j++){
var item = '';
for(var i=0;i<nubCount;i++){
item = arrdef[Math.floor(Math.random()*arrdef.length)] + item;
console.log(item);
}
arr.push(item)
}
}else{
var arrdef = inputValue.split("");
for(var j=0;j<gCount;j++){
var item = '';
for(var i=0;i<nubCount;i++){
item = arrdef[Math.floor(Math.random()*arrdef.length)] + item;
console.log(item);
}
arr.push(item)
}
}
// Generate a random number of ten letters and numbers
// duplicate removal
var ukeys = [];
for (var i = 0; i < arr.length; i++) {
if (ukeys.indexOf(arr[i]) == -1) {
ukeys.push(arr[i]);
}
}
// Array processing , Easy to do Html The document shows
var keys = '';
for (var i=0;i<ukeys.length;i++) {
ukeys[i] += '<br>'
keys += ukeys[i]
}
$('#keys').html(keys);
console.log(' Number of passwords after de duplication :' + ukeys.length);
}
function cleanGenValue(){
$("#inputValue").val("");
this.genValue();
}
</script>
</html>
版权声明
本文为[Move up]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220558499101.html
边栏推荐
- RC低通滤波器的逆系统
- 简单的拖拽物体到物品栏
- Go 语言中的 logger 和 zap 日志库
- eksctl 部署AWS EKS
- Record the blind injection script
- New terminal play method: script guidance independent of technology stack
- Leetcode004 -- Roman numeral to integer
- Effects of antibiotics on microbiome and human health
- Installation and use of Apache bench (AB pressure test tool)
- Flink's important basics
猜你喜欢

Experience summary and sharing of the first prize of 2021 National Mathematical Modeling Competition

基于英飞凌MCU GTM模块的无刷电机驱动方案开源啦

Small volume Schottky diode compatible with nsr20f30nxt5g

How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics

383. Ransom letter

QML advanced (IV) - drawing custom controls

Druid -- JDBC tool class case

【论文阅读】【3d目标检测】Voxel Transformer for 3D Object Detection

IDE idea automatic compilation and configuration of on update action and on frame deactivation

Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000
随机推荐
mysql table 中增加列的SQL语句
Go反射—Go语言圣经学习笔记
1个需求的一生,团队协作在云效钉钉小程序上可以这么玩
C language: Advanced pointer
Bridge between ischemic stroke and intestinal flora: short chain fatty acids
leetcode001--返回和为target的数组元素的下标
383. Ransom letter
Fusobacterium -- symbiotic bacteria, opportunistic bacteria, oncobacterium
leetcode004--罗马数字转整数
Leetcode001 -- returns the subscript of the array element whose sum is target
Spark small case - RDD, broadcast
Use recyclerview to realize left-right side-by-side classification selection
Record the ThreadPoolExecutor main thread waiting for sub threads
Supplement 14: cmake practice project notes (to be continued 4 / 22)
Spark optimization
Differences among electric drill, electric hammer and electric pick
test
Installation and deployment of Flink and wordcount test
重剑无锋,大巧不工
Go reflection - go language Bible learning notes