1. demo.html
<html>
<head></head>
<body>
<form id='formseting' name='form1' method='POST' >
<br>
<input type="text" id = "lowerId" name="lowerMac">
<br>
<input type="text" id = "upperId" name="upperMac">
<input type="submit" value="Submit">
<script>
function print(msg) { document.write(msg);}
function f1() {return Math.floor(Math.random()*255+1);};
function f2(x){
if(x < 10) return "0"+x;
else if(x < 16) return "0"+String.fromCharCode(x+55);
else return x.toString(16);
};
function getVar(id) { return document.getElementById(id); };
function toupperStr (str){
var result = '';
for(var i= 0;i<str.length;i++){
var temp = str.charAt(i);
var code = temp.charCodeAt();
if('a' <= temp && temp <= 'z'){
temp= String.fromCharCode(code-32);
}
result += temp;
}
return result;
}
function generateMacLower(){
var s = "00-" + f2(f1()) +"-" + f2(f1()) +"-" + f2(f1()) +"-" + f2(f1()) +"-" + f2(f1());
return s;
}
function generateMac(){
var ss = generateMacLower();
return toupperStr(ss);
}
var macLower = generateMacLower();
var macstr = toupperStr(macLower);
getVar("lowerId").value = macLower;
getVar("upperId").value = macstr;
for(var i=0;i<256;i++)
{
print(f2(i));
print(" ");
}
</script>
</form>
</body>
</html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
2. 实际效果
