做一个模拟股票交易系统,没有要求搜索,但还是想到,前几天写的stuggest。 在首页加了这个功能。 首页代码: <%@ page language="java" import="java.util.*" pageEncoding="gbk"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'login1.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css"> --> <mce:style><!-- .suggestcss{ border : 1xp solid #000000; background-color : #fofofo; width : 300px; text-align : left; padding : 4px; visibility=hidden; } .cssUserInput{ font-family : verdana; font-size : 12pt; font-weigth : bold; width : 92%; } * {margin:0;padding:0;font-size:12px;} html,body {height:100%;width:100%;} #content {background:#f8f8f8;padding:30px;height:100%;} #content a {font-size:30px;color:#369;font-weight:700;} #ss {font-size:30px;color:#369;font-weight:700;} #alert {border:1px solid #369;width:300px;height:150px;background:#e2ecf5;z-index:1000;position:absolute;display:none;} #alert h4 {height:20px;background:#369;color:#fff;padding:5px 0 0 5px;} #alert h4 span {float:left;} #alert h4 span#mclose {margin-left:210px;font-weight:500;cursor:pointer;} #alert p {padding:12px 0 0 30px;} #alert p input {width:120px;margin-left:20px;} #alert p input.myinp {border:1px solid #ccc;height:16px;} #alert p input.sub {width:60px;margin-left:30px;} #reg {border:1px solid #369;width:400px;height:200px;background:#e2ecf5;z-index:1000;position:absolute;display:none;} #reg h4 {height:20px;background:#369;color:#fff;padding:5px 0 0 5px;} #reg h4 span {float:left;} #reg h4 span#rclose {margin-left:300px;font-weight:500;cursor:pointer;} #reg p {padding:12px 0 0 30px;} #reg p input {width:120px;margin-left:20px;} --></mce:style><style mce_bogus="1"> .suggestcss{ border : 1xp solid #000000; background-color : #fofofo; width : 300px; text-align : left; padding : 4px; visibility=hidden; } .cssUserInput{ font-family : verdana; font-size : 12pt; font-weigth : bold; width : 92%; } * {margin:0;padding:0;font-size:12px;} html,body {height:100%;width:100%;} #content {background:#f8f8f8;padding:30px;height:100%;} #content a {font-size:30px;color:#369;font-weight:700;} #ss {font-size:30px;color:#369;font-weight:700;} #alert {border:1px solid #369;width:300px;height:150px;background:#e2ecf5;z-index:1000;position:absolute;display:none;} #alert h4 {height:20px;background:#369;color:#fff;padding:5px 0 0 5px;} #alert h4 span {float:left;} #alert h4 span#mclose {margin-left:210px;font-weight:500;cursor:pointer;} #alert p {padding:12px 0 0 30px;} #alert p input {width:120px;margin-left:20px;} #alert p input.myinp {border:1px solid #ccc;height:16px;} #alert p input.sub {width:60px;margin-left:30px;} #reg {border:1px solid #369;width:400px;height:200px;background:#e2ecf5;z-index:1000;position:absolute;display:none;} #reg h4 {height:20px;background:#369;color:#fff;padding:5px 0 0 5px;} #reg h4 span {float:left;} #reg h4 span#rclose {margin-left:300px;font-weight:500;cursor:pointer;} #reg p {padding:12px 0 0 30px;} #reg p input {width:120px;margin-left:20px;}</style> <mce:script type="text/javascript" src="<%=basePath%><!-- js/jquery-1.2.6.download.js"> // --></mce:script> <mce:script type="text/javascript"><!-- function handleRequest9(data) { var sp = $("#esp"); sp.html(data); } function checkEmail() { var email=document.regform.email.value ; var Expression= /(/S)+[@]{1}(/S)+[.]{1}(/w)+/; var objExp=new RegExp(Expression); var date=new Date(); var sp = $("#esp"); if(objExp.test(email)==true) { var emailValue = $("#regemail").val()+date; $.get("<%=basePath%>login.do?method=checkEmail&email="+emailValue, null,handleRequest9); }else{ sp.html("请输入正确的邮箱号 "); } } function checkPass(){ var pass; var len; var pass=document.regform.password.value ; len=pass.length; var sp1 = $("#psp"); if(pass==""){ sp1.html("请输入密码! "); } else{ sp1.html(""); if(len>0&&len<4){ sp1.html("密码过短 !"); } else{ var Expression=/^[A-Za-z0-9]+$/; var objExp=new RegExp(Expression); if(objExp.test(pass)==false){ sp1.html("密码格式不正确!"); } } } } function checkName(){ var name = document.regform.name.value ; var sp = $("#nsp"); if(name==""){ sp.html("用户名不能为空!"); } } function checkPhono(){ var name = document.regform.phone.value ; var sp = $("#phsp"); if(name==""){ sp.html("联系电话不能为空!"); } } function checkAddress(){ var address = document.regform.address.value ; var sp = $("#adsp"); if(address==""){ sp.html("住址不要忘记填!"); } } function checkAll(){ var t1=$('#nsp').text(); var t2=$('#esp').text(); var t3=$('#psp').text(); var t4=$('#phsp').text(); var t5=$('#adsp').text(); if(t1==""&t2==""&t3==""&t4==""&t5=="") { return true; } else{ return false; } } function select1(){ //alert(text); var text=$('#text').val(); var text = encodeURI(text); var text = encodeURI(text); //alert(text); $.get("<%=basePath%>holding.do?method=homeOpenView&code="+text, null,handleRequest3); } function handleRequest3(data){ var sp = $("#ss"); sp.html(data); } // --></mce:script> <mce:script type="text/javascript"><!-- keyup=38; keydo=40; keyenter=13; keyCodePressed=null; currentsuggest=0; numsuggest=0; previoussuggest=0; function ajax(){ var text=$("#text").val(); var text = encodeURI(text); var text = encodeURI(text); $.get("<%=basePath%>holding.do?method=homeStockView&text="+text, null,handleRequest); } function handleRequest(data){ var sp1 = $("#pp"); suggestdiv=document.getElementById("pp"); sp1.html(data); //suggest.style.visibility="visible"; customstring(); } document.οnkeydοwn=keydown; if((document.layers)?true:false){ document.captureEvents(Event.KEYDOWN) } function customstring(){ //按键控制suggest suggestdiv=document.getElementById("pp"); if(numsuggest>0){ for(var i=1;i<=numsuggest;i++){ document.getElementById("suggest"+i).οnmοuseοver=function(){this.style.backgroundColor = "#A3D1D1";}; document.getElementById("suggest"+i).οnmοuseοut=function(){this.style.backgroundColor = "#ffffff";}; document.getElementById("suggest"+i).οnclick=function(){ document.form.text.value = $(this).text(); suggestdiv.style.visibility="hidden"; currentsuggest=0; numsuggest=0; previoussuggest=0; return false; //$("#text").focus(); } } } if(document.form.text.value==""){ currentsuggest=0; previoussuggest=0; keyCodePressed=null; suggestdiv.style.visibility="hidden"; } if(keyCodePressed==keyenter){ if(suggestdiv.style.visibility=="hidden"){ alert("ho"); return; } else{ if(currentsuggest>0){ document.form.text.value = $("#suggest"+currentsuggest).text(); //alert(document.form.text.value); suggestdiv.style.visibility="hidden"; currentsuggest=0; numsuggest=0; previoussuggest=0; return false; } } } if(keyCodePressed==keyup||keyCodePressed==keydo){ //上下键 if(previoussuggest>0){ document.getElementById("suggest"+previoussuggest).style.backgroundColor="#ffffff"; } if(keyCodePressed==keyup){ currentsuggest--; if(currentsuggest<1){ currentsuggest=numsuggest; } } if(keyCodePressed==keydo){ currentsuggest++; if(currentsuggest>numsuggest){ currentsuggest=1; } } //alert(currentsuggest); document.getElementById("suggest"+currentsuggest).style.backgroundColor = "#A3D1D1"; } previoussuggest=currentsuggest; //alert(currentsuggest); //if(keyCodePressed==keyup) //document.getElementById("suggest1").style.backgroundColor = "#C4E1FF"; } function keydown(e){ //按键事件 ev=(e)?e:(window.event)?window.event:null; if(ev){ keyCodePressed = (ev.charCode)?ev.charCode:((ev.keyCode)?ev.keyCode : ((ev.which)?ev.which : null)); //alert(keyCodePressed); } } // --></mce:script> </head> <body > <div id="content"> <center> <a style= "cursor:hand; "> 登录</a> <a style= "cursor:hand; "> 注册</a> <a style= "cursor:hand; " href="<%=basePath%>back.do?method=backStageView" style="TEXT-DECORATION:none"> 后台</a> </center><br> <center> <form id ="form" name="form" onSubmit="return false;"> <br> <input type="text" autoComplete="Off" name="text" id ="text" class="cssUserInput" style="width:300px" οnkeyup="ajax()" /><br> <div id ="pp" class="suggestcss"> </div> <input type="button" id="sbut" value="搜索" οnclick="select1()" > </form> <br> <a id="ss"> </a> <br> <br> <img alt="ss" src="images/bg.gif" mce_src="images/bg.gif">> </center> </div> <div id="alert"> <h4><span>欢迎登录</span><span id="mclose">关闭</span></h4> <form name="logform"action="<%=basePath%>login.do?method=loginUser" method="post"> <p><label>用户名</label><input name="name" type="text" class="myinp" οnmοuseοver="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" οnblur="this.style.border='1px solid #ccc'" /></p> <p><label>密 码</label><input name="password" type="password" class="myinp" οnmοuseοver="this.style.border='1px solid #f60'" onfoucs="this.style.border='1px solid #f60'" οnblur="this.style.border='1px solid #ccc'" /></p> <p><input type="submit" value="登录" class="sub" /><input type="reset" value="重置" class="sub" /></p> </form> </div> <div id="reg"> <h4><span>欢迎注册</span><span id="rclose">关闭</span></h4> <form name="regform" action="<%=basePath%>login.do?method=insertUser" method="post"> <p><label>用户姓名:</label><input type="text" name="name" οnblur="checkName()"> <span style="color: red" mce_style="color: red" id="nsp"></span><br></p> <p><label> 用户密码:</label><input type="password" name="password" οnblur="checkPass()"> <span style="color: red" mce_style="color: red" id="psp" ></span><br></p> <p><label> 邮 箱:</label><input type="text" name="email" id="regemail" οnblur="checkEmail()"> <span style="color: red" mce_style="color: red" id="esp"></span><br></p> <p><label> 联系电话:</label><input type="text" name="phone"οnblur="checkPhono()"> <span style="color: red" mce_style="color: red" id="phsp"></span><br></p> <p><label> 联系住址:</label><input type="text" name="address" οnblur="checkAddress()"> <span style="color: red" mce_style="color: red" id="adsp"></span><br></p> <p><input type="submit" value="提交注册"/> </p> </form> <br> </div> <mce:script type="text/javascript"><!-- var myAlert = document.getElementById("alert"); var login = document.getElementById("content").getElementsByTagName("a")[0]; var mClose = document.getElementById("mclose"); var RAlert = document.getElementById("reg"); var register=document.getElementById("content").getElementsByTagName("a")[1]; var rClose = document.getElementById("rclose"); login.onclick = function() { myAlert.style.display = "block"; myAlert.style.position = "absolute"; myAlert.style.top = "50%"; myAlert.style.left = "50%"; myAlert.style.marginTop = "-75px"; myAlert.style.marginLeft = "-150px"; mybg = document.createElement("div"); mybg.setAttribute("id","mybg"); mybg.style.background = "#000"; mybg.style.width = "100%"; mybg.style.height = "100%"; mybg.style.position = "absolute"; mybg.style.top = "0"; mybg.style.left = "0"; mybg.style.zIndex = "500"; mybg.style.opacity = "0.3"; mybg.style.filter = "Alpha(opacity=30)"; document.body.appendChild(mybg); document.body.style.overflow = "hidden"; } register.οnclick= function(){ RAlert.style.display = "block"; RAlert.style.position = "absolute"; RAlert.style.top = "35%"; RAlert.style.left = "45%"; RAlert.style.marginTop = "-75px"; RAlert.style.marginLeft = "-150px"; mybg = document.createElement("div"); mybg.setAttribute("id","mybg"); mybg.style.background = "#000"; mybg.style.width = "100%"; mybg.style.height = "100%"; mybg.style.position = "absolute"; mybg.style.top = "0"; mybg.style.left = "0"; mybg.style.zIndex = "500"; mybg.style.opacity = "0.3"; mybg.style.filter = "Alpha(opacity=30)"; document.body.appendChild(mybg); document.body.style.overflow = "hidden"; } rClose.onclick = function() { RAlert.style.display = "none"; mybg.style.display = "none"; } mClose.onclick = function() { myAlert.style.display = "none"; mybg.style.display = "none"; } // --></mce:script> </body> </html>