Html代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
function checkuser() {
if($(‘uname‘ == "lala") && $(‘pwd‘) == "123") {
return true;
}else {
return false;
}
}
function $(id) {
return document.getElementById(id).value;
}
</script>
</head>
<body>
<form action="ok.html">
u:<input type="text" id="uname"/><br>
p:<input type="password" id="pwd"/><br>
<input type="submit" value="登录" onclick="return checkuser()"/>
</form>
</body>
</html>
JavaScript代码
window.onload = function () {
var oName = document.getElementById(‘txt1‘);
var oEasyName = document.getElementById(‘txt2‘);
var oHero = document.getElementById(‘txt3‘);
var oBtn = document.getElementById(‘btn‘);
var oTab = document.getElementById(‘tab1‘);
var num = oTab.tBodies[0].rows.length + 1;
oBtn.onclick = function () {
var oTr = document.createElement(‘tr‘);
var oTd = document.createElement(‘td‘)
oTd.innerHTML = num++;
oTr.appendChild(oTd);
var oTd = document.createElement(‘td‘);
oTd.innerHTML = oName.value;
oTr.appendChild(oTd);
var oTd = document.createElement(‘td‘);
oTd.innerHTML = oEasyName.value;
oTr.appendChild(oTd);
var oTd = document.createElement(‘td‘);
oTd.innerHTML = oHero.value;
oTr.appendChild(oTd);
var oTd = document.createElement(‘td‘);
oTd.innerHTML = ‘删除‘;
oTr.appendChild(oTd);
oTd.getElementsByTagName(‘a‘)[0].onclick = function () {
oTab.tBodies[0].removeChild(this.parentNode.parentNode);
}
oTab.tBodies[0].appendChild(oTr);
}
};
Java代码
/**
* 测试手机号码是来自哪个城市的,利用淘宝的API
* @param mobileNumber 手机号码
* @return
* @throws MalformedURLException
*/
public static String calcMobileCity(String mobileNumber) throws MalformedURLException{
String jsonString = null;
JSONArray array = null;
JSONObject jsonObject = null;
String urlString = "http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=" + mobileNumber;
StringBuffer sb = new StringBuffer();
BufferedReader buffer;
URL url = new URL(urlString);
try{
InputStream in = url.openStream();
// 解决乱码问题
buffer = new BufferedReader(new InputStreamReader(in,"gb2312"));
String line = null;
while((line = buffer.readLine()) != null){
sb.append(line);
}
in.close();
buffer.close();
// System.out.println(sb.toString());
jsonString = sb.toString();
// 替换掉“__GetZoneResult_ = ”,让它能转换为JSONArray对象
jsonString = jsonString.replaceAll("^[__]\\w{14}+[_ = ]+", "[");
// System.out.println(jsonString+"]");
String jsonString2 = jsonString + "]";
// 把STRING转化为json对象
array = JSONArray.fromObject(jsonString2);
// 获取JSONArray的JSONObject对象,便于读取array里的键值对
jsonObject = array.getJSONObject(0);
}catch(Exception e){
e.printStackTrace();
}
return jsonObject.getString("province");
}
SQL代码
select student_id as ‘学号‘,student.sname as ‘学生姓名‘
from score left join student
on score.student_id=student.sid
/*查询条件:学生学习的课程在【学号为“002”的同学所学的课程科目】中*/
where score.corse_id in(select corse_id from score where student_id=1)
/*排除自身,即不包括002同学自己*/
and student_id!=1
group by student_id
/*分组条件:在上方查询条件的基础上,保证学习的课程总数相同*/
having count(score.corse_id)=(select count(corse_id) from score where student_id=1)
order by student_id;
select student_id as ‘学号‘,student.sname as ‘学生姓名‘,count(corse_id),count(student_id)
from score left join student
on score.student_id=student.sid
/*查询条件:学生学习的课程在【学号为“002”的同学所学的课程科目】中*/
where score.corse_id in(select corse_id from score where student_id=1)
/*排除自身,即不包括002同学自己*/
and student_id!=1
group by student_id
having count(score.corse_id)=(select count(corse_id) from score where student_id=1)
SQL
---创建班级表
create table class(
cid int auto_increment primary key,
caption varchar(20)
)engine=innodb default charset=utf8;
---创建学生表
create table student(
sid int auto_increment primary key,
sname varchar(20),
gender varchar(10) default ‘男‘,
class_id int
)engine=innodb default charset=utf8;
原文:http://www.cnblogs.com/hellojesson/p/6284586.html