我有这个javascript。
$(function () {
$("#generate").click(function () {
$("#number1").val(generateNumb);
#$("#number2");
#$("#number3");
#$("#number4");
});
});
function generateNumb() {
return "000000" + random(10, 16777215).toString(16).toUpperCase();
}
function random(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
这个html:
<body>
<h1>Number Generator</h1 >
<div>
<input id="generate" type=button value="Generate" /><br/><br/>
Number<br/>
<input id="number1" placeholder="Number 1" /><br/>
<input id="number2" placeholder="Number 2" /><br/>
<input id="number3" placeholder="Number 3" /><br/>
<input id="number4" placeholder="Number 4" /><br/>
</div>
</body>
我想添加脚本&#39;#number2&#39;,&#39;#number3&#39;和#number4,它们各自的值是从前一个生成的值开始的增量,意思是:
如何做到这一点?
提前谢谢。
答案 0 :(得分:1)
您可以尝试:
MobilenetV1/Conv2d_0/weights
答案 1 :(得分:1)
几乎最终的解决方案可以实现为:
$(function() {
$("#generate").click(function() {
var increaseBy = increaseBase(generateNumb());
$("#number1").val(increaseBy(0));
$("#number2").val(increaseBy(1));
$("#number3").val(increaseBy(2));
$("#number4").val(increaseBy(3));
});
});
function increaseBase(base) {
return function(value) {
return "000000" + (base + value).toString(16).toUpperCase()
}
}
function generateNumb() {
return random(10, 16777215);
}
function random(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Number Generator</h1>
<div>
<input id="generate" type=button value="Generate" /><br/><br/> Number
<br/>
<input id="number1" placeholder="Number 1" /><br/>
<input id="number2" placeholder="Number 2" /><br/>
<input id="number3" placeholder="Number 3" /><br/>
<input id="number4" placeholder="Number 4" /><br/>
</div>
&#13;
答案 2 :(得分:1)
就我个人而言,我只是制作一小部分代码:
//create your number
function generateNumb() {
return random(10, 16777215)
}
//call this to output your number in your forms
function toHex(num) {
return "000000" + num.toString(16).toUpperCase();
}
function random(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
然后,您可以通过调用以下方法调用这些值:
first = generateNumb();
second = first + parseInt("02", 16);
然后通过调用toHex(first)
输出值。或者您可以立即执行此操作:
firstHex = toHex(generateNumb);
secondHex = toHex(generateNumb+parseInt("02",16));
演示:Fiddle