3. Jquery表單驗證(只能輸入數字,檢查複選框)
<html>
<head>
<title></title>
<style type="text/css">
#error
{
padding-left:15px;
color:Red;
}
</style>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#error").hide();
$("#Button1").click(function () {
var $val = $("#Text1").val();
var code;
for (var i = 0; i < $val.length; i++) {
//charAt()獲取指定位置字符串,charCodeAt()返回該字符串的編碼
//0的ASCII是48,9的ASCII是57
var code = $val.charAt(i).charCodeAt(0);
if (code < 48 || code > 57) {
$("#error").show();
break;
}
else {
$("#error").hide();
}
}
});
});
</script>
</head>
<body>
<div>
Name:<input id="Text1" type="text" /><span id="error">Please enter numeric</span>
</div>
<input id="Button1" type="button" value="button" />
</body>
</html>
2.檢查複選框是否被選中
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#error
{
padding-left:15px;
color:Red;
}
</style>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#error").hide();
$("#Button1").click(function () {
var $val = '';
var count = $('input:checkbox:checked').length;
if (count == 0) {
$("#error").show();
}
else {
$("#error").hide();
$("input:checkbox").each(function () {
if ($(this).is(':checked')) {
$val += $(this).val();
}
})
alert($val);
}
});
});
</script>
</head>
<body>
<div>
<input id="Checkbox1" type="checkbox" value='Hotdogs $2' />Hotdogs $2<br />
<input id="Checkbox2" type="checkbox" value='Chocolate $5' />Chocolate $5<br />
<input id="Checkbox3" type="checkbox" value='Cake $3' />Cake $3<br />
<input id="Checkbox4" type="checkbox" value='Ice $4' />Ice Crime $4<br />
<span id="error">Please select checkbox as least</span>
</div>
<input id="Button1" type="button" value="button" />
</body>
</html>
4 改錯:
public class Something {
public int addOne(final int x) {
return ++x;
}
}
這個比較明顯。
答案: 錯。int x被修飾成final,意味着x不能在addOne method中被修改。
5 Jsp內置對象及其方法。
6.冒泡法
7.用一條sql語句查詢出“每門”課程都大於80分的學生姓名
Name chengji fengshu 張三 數學 75 張三 語文 81 李四 數學 90 李四 語文 76 王五 數學 81 王五 語文 100 王五 英語 90
思路:先查出低於80分的學生名單,然後再用姓名作爲條件對比,排除剛纔查到的學生 SQL Server: select distinct [Name] from [表] where [Name] not in ( select [Name] from [表] where [fengshu]<=80 )
2. 在web應用開發過程中經常遇到輸出某種編碼的字符,如ISO8859-1等 如何輸出一個某一種編碼的字符串?