页面打开时需要采取措施并删除底部
<form name="randform">
Account Number: <input type="text" name="randomfield" value="">
<input type="button" value="Create Account Number" onClick="randomString();">
需要代码随时打开随机数
function randomString() {
var chars = "0123456789";
var string_length = 10;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
document.randform.randomfield.value = randomstring;
}
答案 0 :(得分:0)
//页面打开时需要采取行动
尝试使用window.onload
<script>
function randomString() {
var chars = "0123456789";
var string_length = 10;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
document.randform.randomfield.value = randomstring;
}
window.onload = randomString;
</script>
<form name="randform">
Account Number:
<input type="text" name="randomfield" value="">
<input type="button" value="Create Account Number" onclick="randomString();">
</form>
&#13;
答案 1 :(得分:0)
<script>
var main_form = "[data-inSet=hook]";
var ActionFild = "[data-inSet=randomfield]";
$(main_form).ready(function () {
//the Function You want To Fire -=>
//i am just traing to get window height and output in consol :-p
console.log( window.innerHeight+"px");//my action
});
/*
u can also run the function if the input load . just change $(main_form) -=> [ to ] <=-$(ActionFild);
need more info plz comment bellow
*/``
</script>