2014年5月5日 星期一
2014年4月28日 星期一
lab 20
<html>
<body>
<form name="f" action="http://maps.google.com/" method="get" onsubmit="return check()">
Search: <input type="text" name="q" value=""><br>
<input type="submit" value="Search">
</form>
<script>
function check(){
var floatReg=/^([+-]?)[1-9]\d*(\.\d*)?,([+-]?)[1-9]\d*(\.\d*)?$/;
if(!floatReg.test(f.q.value)){
alert("please try it again");
f.q.value="";
document.f.q.focus();
return false;
}
}
</script>
</body>
</html>
2014年4月15日 星期二
lab 15
<html>
<body>
<button onclick="buildTable()">Try it</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>
2014年4月7日 星期一
訂閱:
文章 (Atom)




