自己做的非常简陋的点选学校的效果

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册页面</title>
<link href="../css/validator.css" type="text/css" rel="stylesheet"></link>
<style type="text/css">
body{
margin:0px auto;
text-align:center;
}
#pop{
background-color:blue;
margin-top:-250px;
}
</style>
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript">
var TableCol=4;
var access=false;
var ja=[];
ja[0]="北京大学";
ja[1]="山东大学";
ja[2]="齐鲁软件学院";
ja[3]="青岛大学";
ja[4]="山东师范大学";
$(document).ready(function (){
alert("ss");
$('#selectSchool').click(function(){
alert("ss");
if(access)
{
$('#pop').show();
}
else
{
/**
$.ajax({
url:'../servlet/GetSchoolname',
type:'GET',
data:{'q':'',time:new Date()},
dataType:'text',
success:function(data){
data=unescape(unescape(data));
ja=data.split("\n");
TableCol=getCol(ja.length);
showSchool();
}
});
*/
TableCol=getCol(ja.length);
showSchool();
}
})
function showSchool(){
var table=$('table',$('#pop'));
$('#pop').html(generate()).show();
$('div#title>a').click(function (){
$('#pop').hide();
});
$('table td',$('#pop')).each(function (i){
$(this).click(function (){
$('#school').val($(this).html());
$('#pop').hide();
});
})
access=true;
}
function generate()
{
var res="";
res+="<div id='title'><a href='#'><font color='red'>关闭</font></a></div>";
var i,j=0;
res+="<div id='content'><table class='schoolTable' border=1>";
while(j<(ja.length/TableCol))
{
res+="<tr>";
for (i = 0; i < TableCol; i = i + 1) {
if ((j*TableCol+i) >= ja.length)
{
break;
}
res+="<td>";
res+=ja[j*TableCol+i];
res+="</td>";
}
res+="</tr>";
j++;
}
res+="</table></div>";
return res;
}
function getCol(num)
{
for(var i=0;i<num;i=i+1)
{
if(i*i>num)
{
break;
}
}
return i;
}
</script>
</head>
<body>
<form method="post" name="form1" id="form1" >
<table border="0px" style="font-size:12px" width="400px">
<tr>
<td>所在学校:</td>
<td><input name="school" type="text" id="school" maxlength="50" /></td>
<td><input type="button" id="selectSchool" value="选择学校"/></td>
</tr>

<tr>
<td colspan="3" align="left" >
<td width="50px"><input type="submit" name="button" id="button" value="提交" /></td>
</tr>
</table>
<div id="pop"></div>
</form>
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值