把JS数组遍历放另外一个JS里面怎么弄?
<scriptLANGUAGE="JavaScript">functionusername(){b=newArray(6);//设定数量,如果数为3,这个参数就设为2,依...
<script LANGUAGE="JavaScript">
function username(){
b= new Array(6); //设定数量,如果数为3,这个参数就设为2,依次类推
p = new Array(6);
b[0] = '111'
p[0] = '111'
b[1] = '2222'
p[1] = '222'
b[2] = '333'
p[2] = '333'
b[3] = '444'
p[3] = '4444'
b[4] = '5555'
p[4] = '5555'
b[5] = '6666'
p[5] = '6666'
b[6] = '7777'
p[6] = '7777'
index = Math.floor(Math.random() * b.length);
document.getElementById('user').value=b[index]
document.getElementById('pass').value=p[index]
}
</script>
把b和p 数组放另外一个JS里面然后在上面调用,因为可能会有几百个数组,不可能都写在同一个JS里面呀 展开
function username(){
b= new Array(6); //设定数量,如果数为3,这个参数就设为2,依次类推
p = new Array(6);
b[0] = '111'
p[0] = '111'
b[1] = '2222'
p[1] = '222'
b[2] = '333'
p[2] = '333'
b[3] = '444'
p[3] = '4444'
b[4] = '5555'
p[4] = '5555'
b[5] = '6666'
p[5] = '6666'
b[6] = '7777'
p[6] = '7777'
index = Math.floor(Math.random() * b.length);
document.getElementById('user').value=b[index]
document.getElementById('pass').value=p[index]
}
</script>
把b和p 数组放另外一个JS里面然后在上面调用,因为可能会有几百个数组,不可能都写在同一个JS里面呀 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询