<input type="text" value="Test" id="Test" />
<button id="btn">提交</button>
<script>
var jschars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
function generateMixed(n) {//n代表生成随机数位数
var res = "";
for(var i = 0; i < n ; i ++) {
var id = Math.ceil(Math.random()*35);
res += jschars[id];
}
Test.value=res;
}
btn.onclick = function(){
generateMixed(7)
}
</script>
网友评论