当前位置:网站首页>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
边栏推荐
- thymeleaf th:value 为null时报错问题
- Bridge between ischemic stroke and intestinal flora: short chain fatty acids
- 2019 is coming to an end, the longest day.
- Go反射—Go语言圣经学习笔记
- leetcode002--将有符号整数的数字部分反转
- Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
- Youqilin 22.04 lts version officially released | ukui 3.1 opens a new experience
- MySQL - data read / write separation, multi instance
- test
- Use recyclerview to realize left-right side-by-side classification selection
猜你喜欢
Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU
C language: Advanced pointer
Installation du compilateur croisé de la plateforme zynq
Unity RawImage背景无缝连接移动
How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics
Ali's ten-year technical experts jointly created the "latest" jetpack compose project combat drill (with demo)
Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
Recommended scheme of national manufactured electronic components for intelligent electronic scales
QML advanced (IV) - drawing custom controls
C language: spoof games
随机推荐
leetcode008--实现strStr()函数
Last day of 2017
IEEE Transactions on systems, man, and Cybernetics: Notes for systems (TSMC)
那些年我面试过的Android开发岗总结(附面试题+答案解析)
[paper reading] [3D target detection] point transformer
/etc/bash_ completion. D directory function (the user logs in and executes the script under the directory immediately)
Supplément: annotation
AWS eks add cluster user or Iam role
How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics
Use recyclerview to realize left-right side-by-side classification selection
Iron and intestinal flora
A heavy sword without a blade is a great skill
Supplement: Annotation
RC低通滤波器的逆系统
Recommended scheme of national manufactured electronic components
Recursive call -- Enumeration of permutations
Ali's ten-year technical experts jointly created the "latest" jetpack compose project combat drill (with demo)
QML进阶(四)-绘制自定义控件
Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000
test