2014年4月28日 星期一
Lab 15 九九乘法表
<html>
<body>
<button onclick="buildTable()">來按我吧!</button>
<script>
function buildTable(){
docBody = document.getElementsByTagName("body").item(0)
myTable = document.createElement("TABLE")
myTable.id ="TableOne"
myTable.border = 1
myTableBody = document.createElement("TBODY")
for (i = 1; i <=9; i++){
row = document.createElement("TR")
for (j = 1; j <=9; j++){
cell = document.createElement("TD")
cell.setAttribute("WIDTH","50")
cell.setAttribute("HEIGHT","50")
textVal = i + "*" + j+"="+i*j
textNode = document.createTextNode(textVal)
cell.appendChild(textNode)
row.appendChild(cell)
}
myTableBody.appendChild(row)
}
myTable.appendChild(myTableBody)
docBody.appendChild(myTable)
}
</script>
</head>
<body>
</body>
</html>
<body>
<button onclick="buildTable()">來按我吧!</button>
<script>
function buildTable(){
docBody = document.getElementsByTagName("body").item(0)
myTable = document.createElement("TABLE")
myTable.id ="TableOne"
myTable.border = 1
myTableBody = document.createElement("TBODY")
for (i = 1; i <=9; i++){
row = document.createElement("TR")
for (j = 1; j <=9; j++){
cell = document.createElement("TD")
cell.setAttribute("WIDTH","50")
cell.setAttribute("HEIGHT","50")
textVal = i + "*" + j+"="+i*j
textNode = document.createTextNode(textVal)
cell.appendChild(textNode)
row.appendChild(cell)
}
myTableBody.appendChild(row)
}
myTable.appendChild(myTableBody)
docBody.appendChild(myTable)
}
</script>
</head>
<body>
</body>
</html>
Lab18 change pictures
<img alt="Pulpit rock" border="0" src="http://4.blog.xuite.net/4/0/3/1/15236299/blog_369324/txt/24443066/11.jpg" height="228" onmouseout="src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2jbKxhT7uGrevugF4uowatqMoj2O41P-7ImpU_LRR-cmlKTDiXZoIDx5bfZwZoo4wRLhqnMggNrNYR0Ydp56CEr2CuudQk0bEUxGIrmOE_IMk4Bq2do8GLop8pj1XXNKA9sei5fAwH4VN/s1600/X+JAPAN.png'" onmouseover="src='http://4.blog.xuite.net/4/0/3/1/15236299/blog_369324/txt/24443066/11.jpg'" width="304" />
Lab 16 Change an image by moving the mouse
<!DOCTYPE html>
<html>
<head>
<title>lab16</title>
<script>
function mOver(obj){
obj.setAttribute("src","http://4.blog.xuite.net/4/0/3/1/15236299/blog_369324/txt/24443066/11.jpg");
}
function mOut(obj){
obj.setAttribute("src","http://www.spirit-of-metal.com/les%20goupes/X/X%20Japan/pics/1.jpg");
}
</script>
</head>
<body>
<img border="0" src="http://4.blog.xuite.net/4/0/3/1/15236299/blog_369324/txt/24443066/11.jpg" width="500" height="500" onmouseover="mOver(this)" onmouseout="mOut(this)">
</body>
</html>
lab16
<html>
<head>
<title>lab16</title>
<script>
function mOver(obj){
obj.setAttribute("src","http://4.blog.xuite.net/4/0/3/1/15236299/blog_369324/txt/24443066/11.jpg");
}
function mOut(obj){
obj.setAttribute("src","http://www.spirit-of-metal.com/les%20goupes/X/X%20Japan/pics/1.jpg");
}
</script>
</head>
<body>
<img border="0" src="http://4.blog.xuite.net/4/0/3/1/15236299/blog_369324/txt/24443066/11.jpg" width="500" height="500" onmouseover="mOver(this)" onmouseout="mOut(this)">
</body>
</html>
2014年4月7日 星期一
2014年3月17日 星期一
Lab 13 Regular expression in action II
<html>
<head>
</head>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
<input type="text" id="examplePass" />
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit =function() {
var passwordRegex = /^\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}|\w+\.\w+(\.\\w{1,})*$/;
// var passwordRegex = /^\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}$/;
//var passwordRegex = /^([12]?\d{1,2}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3})|(\w{1,}[.]\w{1,}([.]\w{1,})*)$/;
if(!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify = document.getElementById("notify");
if (notify === null){
notify = document.createElement("p");
notify.textContent = " ERROR ";
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
Lab 12 Regular expression in action
<head>
</head>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
<input type="text" id="examplePass" />
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit =function() {
var passwordRegex = /^[+-]?\d+[.]?\d*[,][+-]?\d+[.]?\d*$/;
if(!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify = document.getElementById("notify");
if (notify === null){
notify = document.createElement("p");
notify.textContent = " ERROR ";
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
訂閱:
文章 (Atom)





