First, you need to generate random numbers not repeated within n, and put the generated random numbers into another Array. Use the following method to complete the process:
Copy codeThe Code is as follows:
Function getRandomNumbers (count)
{
Var numbers = new Array ();
Var original = new Array ();
For (var I = 0; I <count; I ++)
{
Original [I] = I + 1;
}
Original. sort (function () {return 0.5-Math. random ();});
For (var I = 0; I <count; I ++)
{
Numbers [I] = original [I]-1;
}
Return numbers;
}
Then, in the background program, output the html Script:
Copy codeThe Code is as follows:
Var sf = new Array ();
Sf [0] = '<tr> <TD width = 120> <a href = # target = _ blank> server name </a> </TD> <TD width = 110> <a href = http:// SC .jb51.net target = _ blank> Server IP </a> </TD> <TD width = 160> opening time </TD> <TD align = center width = 95> line Category </TD> <TD> Version introduction </TD> <TD width = 105> customer service QQ </TD> <TD align = center width = 55> <a href = # target = _ blank> <font color = #000000> detailed introduction </font> </a> </TD> </tr> ';
Sf [1] = '<tr> <TD width = 120> <a href = # target = _ blank> server name </a> </TD> <TD width = 110> <a href = http://s.jb51.net target = _ blank> Server IP </a> </TD> <TD width = 160> opening time </TD> <TD align = center width = 95> line Category </TD> <TD> Version introduction </TD> <TD width = 105> customer service QQ </TD> <TD align = center width = 55> <a href = # target = _ blank> <font color = #000000> detailed introduction </font> </a> </TD> </tr> ';
Use the previous method to generate a random number and display the html Script according to the random number.
Copy codeThe Code is as follows:
Var numbers = getRandomNumbers (sf. length );
For (I = 0; I <numbers. length; I ++)
{
Document. write (sf [numbers [I]);
}