地铁查询设计思想源代码分析等

在地铁查询系统中,最核心的部分就是算法和数据结构。优秀的算法与数据结构能够在瞬间为用户提供高效准确的查询结果。有些地铁查询系统采用图论中的最短路算法(如Dijkstra算法)来计算地铁站点之间的最短路径和最短时间,这种方法适合较为复杂的线路网情况。另外,还有一些地铁查询系统采用A*算法或其他启发式算法,可以进行更快速的计算,但是会牺牲一定的计算精度。

复制代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="地铁.Thesql"%>
<%@page import="地铁.Pd"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>站点查询</title>
<style type="text/css">
.tabDiv{margin:100px 100px;float:left;}
.tabDiv2{margin:250px 100px;float:left;margin-left:200px;}

.tabs1{margin:100px 50px}
.tabs2{margin:100px 50px}
.tabs3{margin:100px 50px}

.Butn1{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn2{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn3{width:200px;height:72px;margin:100px 50px;font-size: 16px;}

.Butn{width:200px;height:72px;font-size: 30px;display: inline-block;color: blue;}
a{font-size:50px;text-decoration: none;}

</style>

<body>
<div class="tabDiv">
<div>
<div class="Butn1"><button class="Butn" id="button1">换乘查询</button></div>
<div class="Butn2"><button class="Butn" id="button2">线路查询</button></div>
<div class="Butn3"><button class="Butn" id="button3">站点查询</button></div>
</div>
</div>
<div class="tabDiv2">

<div class="tabs1" id="content1" style="display: block">
<table border="1" width="500" cellspacing="0">
<%
                String chufadi=request.getParameter("chufadi");
                String mudidi=request.getParameter("mudidi");
                String[]arr=new String[40];
                Thesql the=new Thesql();
                arr=the.chaxunQiAndZhong(chufadi, mudidi);
                int i=0;
                %><caption>出发点为:<%out.print(chufadi);%></caption>
                <tr>
             
           <th>起点</th>
           <th>线</th>
           <th>站数</th>
           <th>换站点</th>
    </tr>
                <%
                while(arr[i]!=null)
                {
                    %>
                    <tr>
                    <th><%out.print(arr[i]);i++; %></th>
                    <th><%out.print(arr[i]);i++; %></th>
                    <th><%out.print(arr[i]);i++; %></th>
                    <th><%out.print(arr[i]);%></th>
                    </tr>
                    
                    <%
                }
                
%>
</table>
</div>

</div>
<div class="tabs2" id="content2" style="display: none">

<form action="newxianluim.jsp" method="get">
<h1>线路站点查询</h1>
<p class="ys">*</p>
<p>1.需要查询线路名称</p><br>
<select name="xianlu" id="xianlu">
<option value="北京地铁1号线">北京地铁1号线</option>
<option value="北京地铁2号线">北京地铁2号线</option>
<option value="北京地铁4号线">北京地铁4号线</option>
<option value="北京地铁5号线">北京地铁5号线</option>
<option value="北京地铁6号线">北京地铁6号线</option>
<option value="北京地铁7号线">北京地铁7号线</option>
<option value="北京地铁8号线">北京地铁8号线</option>
<option value="北京地铁9号线">北京地铁9号线</option>
<option value="北京地铁10号线">北京地铁10号线</option>
<option value="北京地铁11号线">北京地铁11号线</option>
<option value="北京地铁13号线">北京地铁13号线</option>
<option value="北京地铁14号线">北京地铁14号线</option>
<option value="北京地铁15号线">北京地铁15号线</option>
<option value="北京地铁16号线">北京地铁16号线</option>
<option value="北京地铁17号线">北京地铁17号线</option>
<option value="北京地铁19号线">北京地铁19号线</option>
</select><br>
<input type="submit" value="查询    " /><br>
</form>


</div>
<div class="tabs3" id="content3" style="display: none">

<h1>站点查询</h1>
<p>1.输入需要查询站点名称</p>
<form action="newzhandainim.jsp" method="get">
<input type="text" style="width: 180px;height:20px;border-radius:10px" name="zhandian" /><br>
<input style="width:200px;height:50px;font-size: 30px;display: inline-block;color: blue;" type="submit" value="查询    " /><br>
</form>
</div>

<script type="text/jscript">    
document.getElementById("button1").addEventListener("click", function() {  document.getElementById("content1").style.display = "block";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "none";});
document.getElementById("button2").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "block";  document.getElementById("content3").style.display = "none";});
document.getElementById("button3").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "block";});
</script>
</div>

</body>
</html>
复制代码
复制代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="地铁.Thesql"%>
<%@page import="地铁.Pd"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>站点查询</title>
<style type="text/css">
.tabDiv{margin:100px 100px;float:left;}
.tabDiv2{margin:80px 100px;float:left;margin-left:200px;}

.tabs1{margin:100px 50px}
.tabs2{margin:100px 50px}
.tabs3{margin:100px 50px}

.Butn1{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn2{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn3{width:200px;height:72px;margin:100px 50px;font-size: 16px;}

.Butn{width:200px;height:72px;font-size: 30px;display: inline-block;color: blue;}
a{font-size:50px;text-decoration: none;}

</style>

<body>
<div class="tabDiv">
<div>
<div class="Butn1"><button class="Butn" id="button1">换乘查询</button></div>
<div class="Butn2"><button class="Butn" id="button2">线路查询</button></div>
<div class="Butn3"><button class="Butn" id="button3">站点查询</button></div>
</div>
</div>
<div class="tabDiv2">

<div class="tabs1" id="content1" style="display: none">

<form action="newhuanchengim.jsp" method="get">
<h1>换乘线路查询</h1>
<p class="ys">*</p>
<p>1.输入需要查询出发地</p><br>
<input type="text" name="chufadi" /><br>
<p>1.输入需要查询目的地</p><br>
<input type="text" name="mudidi" /><br>
<input type="submit" value="查询    " /><br>
</form>

</div>
<div class="tabs2" id="content2" style="display: block">
<table border="1" width="500" cellspacing="0">
<%
                String xianlu=request.getParameter("xianlu");
                Thesql the=new Thesql();
                String[]arr=new String[40];
                arr=the.chaxunxianlu(xianlu).zhan;
%> <caption><%out.print(xianlu);%></caption><%
                    int i=0;
                    while(arr[i]!=null)
                    {
                        %>
                        <tr>
                        <td><% out.print(arr[i]);%></td></tr>
                        <%
                        i++;
                    }
%>
</table>
</div>
<div class="tabs3" id="content3" style="display: none">

<h1>站点查询</h1>
<p>1.输入需要查询站点名称</p>
<form action="newzhandainim.jsp" method="get">
<input type="text" style="width: 180px;height:20px;border-radius:10px" name="zhandian" /><br>
<input style="width:200px;height:50px;font-size: 30px;display: inline-block;color: blue;" type="submit" value="查询    " /><br>
</form>
</div>

<script type="text/jscript">    
document.getElementById("button1").addEventListener("click", function() {  document.getElementById("content1").style.display = "block";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "none";});
document.getElementById("button2").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "block";  document.getElementById("content3").style.display = "none";});
document.getElementById("button3").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "block";});
</script>
</div>

</body>
</html>
复制代码
复制代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="地铁.Thesql"%>
<%@page import="地铁.Pd"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>站点查询</title>
<style type="text/css">
.tabDiv{margin:100px 100px;float:left;}
.tabDiv2{margin:80px 100px;float:left;margin-left:200px;}

.tabs1{margin:100px 50px}
.tabs2{margin:100px 50px}
.tabs3{margin:100px 50px}

.Butn1{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn2{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn3{width:200px;height:72px;margin:100px 50px;font-size: 16px;}

.Butn{width:200px;height:72px;font-size: 30px;display: inline-block;color: blue;}
a{font-size:50px;text-decoration: none;}

</style>

<body>
<div class="tabDiv">
<div>
<div class="Butn1"><button class="Butn" id="button1">换乘查询</button></div>
<div class="Butn2"><button class="Butn" id="button2">线路查询</button></div>
<div class="Butn3"><button class="Butn" id="button3">站点查询</button></div>
</div>
</div>
<div class="tabDiv2">
<div class="tabs1" id="content1" style="display: none">

<form action="newhuanchengim.jsp" method="get">
<h1>换乘线路查询</h1>
<p class="ys">*</p>
<p>1.输入需要查询出发地</p><br>
<input type="text" name="chufadi" /><br>
<p>1.输入需要查询目的地</p><br>
<input type="text" name="mudidi" /><br>
<input type="submit" value="查询    " /><br>
</form>

</div>
<div class="tabs2" id="content2" style="display: none">

<form action="newxianluim.jsp" method="get">
<h1>线路站点查询</h1>
<p class="ys">*</p>
<p>1.需要查询线路名称</p><br>
<select name="xianlu" id="xianlu">
<option value="北京地铁1号线">北京地铁1号线</option>
<option value="北京地铁2号线">北京地铁2号线</option>
<option value="北京地铁4号线">北京地铁4号线</option>
<option value="北京地铁5号线">北京地铁5号线</option>
<option value="北京地铁6号线">北京地铁6号线</option>
<option value="北京地铁7号线">北京地铁7号线</option>
<option value="北京地铁8号线">北京地铁8号线</option>
<option value="北京地铁9号线">北京地铁9号线</option>
<option value="北京地铁10号线">北京地铁10号线</option>
<option value="北京地铁11号线">北京地铁11号线</option>
<option value="北京地铁13号线">北京地铁13号线</option>
<option value="北京地铁14号线">北京地铁14号线</option>
<option value="北京地铁15号线">北京地铁15号线</option>
<option value="北京地铁16号线">北京地铁16号线</option>
<option value="北京地铁17号线">北京地铁17号线</option>
<option value="北京地铁19号线">北京地铁19号线</option>
</select><br>
<input type="submit" value="查询    " /><br>
</form>


</div>
<div class="tabs3" id="content3" style="display: block">


<table border="1" width="500" cellspacing="0">
<%
                String zhandian=request.getParameter("zhandian");
                Thesql the=new Thesql();
                Pd[] pdd=new Pd[20];
                String[]arr=new String[40];
                pdd=the.chaxunxianlu2(zhandian);
%> <caption><%out.print(zhandian);%>所在线路为</caption><%
for(int j=0;j<pdd.length;j++)
{
    if(pdd[j].mingcheng!=null)
    %>
    <tr>
    <td><% out.print(pdd[j].mingcheng);%></td></tr>
    <%
    
    for(int i=0;i<35;i++)
    {
        if(pdd[j].zhan[i]!=null)
        %>
        <tr>
        <td><% out.print(pdd[j].zhan[i]);%></td></tr>
        <%
    }
}
%>
</table>


</div>

<script type="text/jscript">    
document.getElementById("button1").addEventListener("click", function() {  document.getElementById("content1").style.display = "block";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "none";});
document.getElementById("button2").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "block";  document.getElementById("content3").style.display = "none";});
document.getElementById("button3").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "block";});
</script>
</div>

</body>
</html>
复制代码
package 地铁;

public class Pd {
    public String mingcheng;
    public String[] zhan=new String[100];
}
    
复制代码
package 地铁;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Thesql {
    public Connection connect;
    public Thesql()throws Exception 
    {
        Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql://localhost:3306/ditie";
        String username="root";
        String password="2223640185";
        connect = DriverManager.getConnection(url,username,password);
    }
    public void finalize() throws Exception
    {
        connect.close();
    }
    //线路号查询,输入线路名称得到线路上的站点信息,String name = 线路名称
    public Pd chaxunxianlu(String name) throws SQLException
    {
        String sql="select * from xinxi where mingcheng='"+name+"'";
        Statement stmt = connect.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        Pd pdd = new Pd();
        while(rs.next())
        {
            pdd.mingcheng=rs.getString(2);
            String zhan="";
            int i=3;
            while(zhan!=null)
            {
                zhan=rs.getString(i);
                pdd.zhan[i-3]=zhan;
                i++;
            }
        }
        stmt.close();
        return pdd;
    }
    //通过站点名称,查出所有经过站点的线路以及对应的线路信息,String name = 站点名称
    public Pd[] chaxunxianlu2(String zhanname) throws Exception
    {
        String[] strings=getxianname(zhanname);
        Pd[] pdd = new Pd[strings.length];
        for(int j=0;j<strings.length;j++)
        {
            pdd[j]=chaxunxianlu(strings[j]);
        }
        return pdd;
    }
    //得到线路名称,String zhanname = 站点名称 ,返回值为字符串数组(可能多条线路),返回内容为线路名称
    public String[] getxianname(String zhanname) throws SQLException
    {
        String[] strings = new String[5];
        Statement stmt = connect.createStatement();
        int num=0;
        for(int i=1;i<36;i++)
        {
            String sql="select * from xinxi where a"+i+" ='"+zhanname+"'";
            ResultSet rs = stmt.executeQuery(sql);
            while(rs.next())
            {
                String n=rs.getString(2);
                strings[num]=n;
            }
            if(strings[num]!=null)
                num++;
        }
        String[] strings2 = new String[num];
        for(int ii=0;ii<num;ii++)
            strings2[ii]=strings[ii];
        stmt.close();
        return strings2;
    }
    //查询最短换乘线,String qidian 为起点 , String zhongdian 为终点
    //起点,线,站数,换站点,线,站数,换站点,线,站数,换站点,线,站数,终点
    public String[] chaxunQiAndZhong(String qidian,String zhongdian) throws Exception 
    {
        
        if(isxiangtong(qidian, zhongdian)!=null)
        {
            String[] jieguo = new String[1];
            jieguo[0]=isxiangtong(qidian, zhongdian);
            String[] jieguo2={qidian,jieguo[0],getchangdu(jieguo[0], qidian, zhongdian)+"",zhongdian};
            return jieguo2;
        }
        else 
        {
            String[] jieguo =getbestjieguo(chaxunduoxian(qidian, zhongdian),qidian,zhongdian);
            String[] jieguo2=new String[100];
            int n =0;
            jieguo2[0]=qidian;
            jieguo2[1]=jieguo[0];
            jieguo2[2]=getchangdu(jieguo[0],qidian,gethuanzhanname(jieguo[0],jieguo[1]))+"";
            jieguo2[3]=gethuanzhanname(jieguo[0],jieguo[1]);
            for(int i=2;i<jieguo.length&&jieguo[i]!=null;i++)
            {
                jieguo2[3*i-2]=jieguo[i-1];
                jieguo2[3*i-1]=getchangdu(jieguo[i-1],gethuanzhanname(jieguo[i-2],jieguo[i-1]),gethuanzhanname(jieguo[i-1],jieguo[i]))+"";
                jieguo2[3*i]=gethuanzhanname(jieguo[i-1],jieguo[i]);
                n=i;
            }
            jieguo2[3*n+1]=jieguo[n];
            jieguo2[3*n+2]=getchangdu(jieguo[0],zhongdian,gethuanzhanname(jieguo[0],jieguo[1]))+"";
            jieguo2[3*n+3]=zhongdian;
            return jieguo2;
        }
    }
    //得到最好线路,将多条起点终点相同的线路比较,得到最短路线
    //String[][] jieguos为多条线路,参考getchangdu(String[] strings,String qidian,String zhongdian)注释
    public String[] getbestjieguo(String[][] jieguos,String qidian,String zhongdian) throws Exception
    {
        String best[] = new String[20];
        int min=1000;
        for(int i=0;i<jieguos.length&&jieguos[i][0]!=null;i++)
        {
            int num = getchangdu(jieguos[i], qidian, zhongdian);
            if(num<min)
            {
                best=jieguos[i];
                min=num;
            }
        }
        return best;
    }
    //得到线路长度 String[] strings={"A线路","B线路","C线路"};
    //例如String[] strings = {"北京地铁房山线","北京地铁9号线","北京地铁14号线","北京地铁15号线"};
    //String qidian 为起点 ,String zhongdian 为终点,返回值为总站数
    public int getchangdu(String[] strings,String qidian,String zhongdian) throws Exception
    {
        int sum=0,n=1;
        sum=getchangdu(strings[0],qidian,gethuanzhanname(strings[0],strings[1]));
        for(int i=2;i<strings.length&&strings[i]!=null;i++)
        {
            sum=sum+getchangdu(strings[i-1],gethuanzhanname(strings[i-2],strings[i-1]), gethuanzhanname(strings[i-1],strings[i]));
            n=i;
        }
        //if(n!=2)
            sum=sum+getchangdu(strings[n],zhongdian,gethuanzhanname(strings[n-1],strings[n]));
        return sum;
    }
    //得到两站之间相隔多少站。String xianname 为所在线路名称,String A,String B,为目标线路上两个点,返回值int为距离
    public int getchangdu(String xianname,String A,String B) throws Exception
    {
        Pd pd = chaxunxianlu(xianname);
        int a=0,b=0;
        for (int i=0;i<pd.zhan.length&&pd.zhan[i]!=null;i++) 
        {
            if(A.equals(pd.zhan[i]))
                a=i;
            if(B.equals(pd.zhan[i]))
                b=i;
        }
        if(a>b)
            return (a-b);
        else 
            return (b-a);
    }
    //查询A和B两站之间所有线路
    //返回值为二维字符串数组
    public String[][] chaxunduoxian(String A,String B) throws Exception 
    {
        String[] jieguo = new String[20];
        String[][] jieguos = new String[1000][20];
        int n=0;
        
        String[] strings = getxianname(A);
        for (int i=0;i<strings.length;i++) 
        {
            String[] huanzhans = gethuanzhanname(strings[i]);
            if(isxiangtong(huanzhans,B)!=null)
            {
                String string =isxiangtong(huanzhans,B);
                jieguo[0]=strings[i];
                jieguo[1]=string;
                jieguos[n]=jieguo;
                n++;
            }
            
            for(int j=0;j<huanzhans.length;j++)
            {
                String[] strings2 = getxianname(huanzhans[j]);
                for (int k=0; k<strings2.length;k++) 
                {
                    String[] huanzhans2 = gethuanzhanname(strings2[k]);
                    if(isxiangtong(huanzhans2,B)!=null)
                    {
                        String string =isxiangtong(huanzhans2,B);
                        jieguo[0]=strings[i];
                        jieguo[1]=strings2[k];
                        jieguo[2]=string;
                        jieguos[n]=jieguo;
                        n++;
                    }
                }
            }
            if(jieguos[0][0] != null)
            {
                return jieguos;
            }else {
                for(int j=0;j<huanzhans.length;j++)
                {
                    String[] strings2 = getxianname(huanzhans[j]);
                    for (int k=0; k<strings2.length;k++) 
                    {
                        String[] huanzhans2 = gethuanzhanname(strings2[k]);
                        for (int l = 0; l < huanzhans2.length; l++) 
                        {
                            String[] strings3 = getxianname(huanzhans2[l]);
                            for (int m = 0; m < strings3.length; m++) 
                            {
                                String[] huanzhans3 = gethuanzhanname(strings3[m]);
                                if(isxiangtong(huanzhans3,B)!=null)
                                {
                                    String string =isxiangtong(huanzhans3,B);
                                    jieguo[0]=strings[i];
                                    jieguo[1]=strings2[k];
                                    jieguo[2]=strings3[m];
                                    jieguo[3]=string;
                                    jieguos[n]=jieguo;
                                    n++;
                                }
                            }
                        }
                    }
                }        
            }
        }
        return jieguos;
    }
    //判断是否相通,String A为单个换站点,String B为终点,
    //返回值为String,若相通返回值为字符串则为相通,字符串为线路名,若为null则不相通
    public String isxiangtong(String A,String B) throws Exception
    {
        String[] strings = getxianname(A);
        String[] strings2 = getxianname(B);
        for(int i=0;i<strings.length;i++) 
        {
            for(int j=0;j<strings2.length;j++) 
            {
                if(strings[i].equals(strings2[j]))
                    return strings[i];
            }
        }
        return null;
    }
    
    //判断是否相通,String[] A为多个换站点,String B为终点,
    //返回值为String,若相通返回值为字符串则为相通,字符串为线路名,若为null则不相通
    public String isxiangtong(String[] A,String B) throws Exception
    {
        int n=A.length;
        for(int k=0;k<n;k++)
        {
            String[] strings = getxianname(A[k]);
            String[] strings2 = getxianname(B);
            for(int i=0;i<strings.length;i++) 
            {
                for(int j=0;j<strings2.length;j++) 
                {
                    if(strings[i].equals(strings2[j]))
                        return strings[i];
                }
            }
        }
        return null;
    }
    
    //得到换站点名称,String xianname为线路名称,返回值为字符串数组,返回多个换站点
    public String[] gethuanzhanname(String xianname) throws SQLException 
    {
        String sql="select * from huanzhan where xian1='"+xianname+"' or xian2='"+xianname+"'";
        Statement stmt = connect.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        String[] strings = new String[30];
        int j = 0;
        while(rs.next())
        {
            strings[j]=rs.getString(2);
            j++;
        }
        String[] strings2 = new String[j];
        for(int ii=0;ii<j;ii++)
            strings2[ii]=strings[ii];
        stmt.close();
        return strings2;
    }
    
    
    //得到换站点名称,String A,String B为交叉的两条地铁线名称,返回值String为换站点名称
    public String gethuanzhanname(String A,String B) throws Exception
    {
        String string=new String();
        String sql="select * from huanzhan where xian1='"+A+"' and xian2='"+B+"'";
        Statement stmt = connect.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        while(rs.next())
        {
            string=rs.getString(2);
        }
        if(!string.equals(""))
        {
            return string;
        }
        else {
            String sql2="select * from huanzhan where xian1='"+B+"' and xian2='"+A+"'";
            Statement stmt2 = connect.createStatement();
            ResultSet rs2 = stmt2.executeQuery(sql2);
            while(rs2.next())
            {
                string=rs2.getString(2);
            }
            if(!string.equals(""))
            {
                return string;
            }
        }
        return null;
    }
    
    
    
    
}
复制代码
复制代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>站点查询</title>
<style type="text/css">
.tabDiv{margin:100px 100px;float:left;}
.tabDiv2{margin:250px 100px;float:left;margin-left:200px;}

.tabs1{margin:10px 50px}
.tabs2{margin:100px 50px}
.tabs3{margin:100px 50px}

.Butn1{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn2{width:200px;height:72px;margin:100px 50px;font-size: 16px;}
.Butn3{width:200px;height:72px;margin:100px 50px;font-size: 16px;}

.Butn{width:200px;height:72px;font-size: 30px;display: inline-block;color: blue;}
a{font-size:50px;text-decoration: none;}

</style>

<body>
<div class="tabDiv">
<div>
<div class="Butn1"><button class="Butn" id="button1">换乘查询</button></div>
<div class="Butn2"><button class="Butn" id="button2">线路查询</button></div>
<div class="Butn3"><button class="Butn" id="button3">站点查询</button></div>
</div>
</div>
<div class="tabDiv2">

<div class="tabs1" id="content1" style="display: block">

<form action="newhuanchengim.jsp" method="get">
<h1>换乘线路查询</h1>
<p>1.输入需要查询出发地</p>
<input type="text" style="width: 180px;height:20px;border-radius:10px" name="chufadi" /><br>
<p>2.输入需要查询目的地</p>
<input type="text" style="width: 180px;height:20px;border-radius:10px" name="mudidi" /><br>
<input style="width:200px;height:50px;font-size: 30px;display: inline-block;color: blue;" type="submit" value="查询    " /><br>
</form>

</div>
<div class="tabs2" id="content2" style="display: none">

<form action="newxianluim.jsp" method="get">
<h1>线路站点查询</h1>
<p>1.需要查询线路名称</p>
<select style="height:30px;border:1px solid gray;font-size:25px;" name="xianlu" id="xianlu">
<option value="北京地铁1号线">北京地铁1号线</option>
<option value="北京地铁2号线">北京地铁2号线</option>
<option value="北京地铁4号线">北京地铁4号线</option>
<option value="北京地铁5号线">北京地铁5号线</option>
<option value="北京地铁6号线">北京地铁6号线</option>
<option value="北京地铁7号线">北京地铁7号线</option>
<option value="北京地铁8号线">北京地铁8号线</option>
<option value="北京地铁9号线">北京地铁9号线</option>
<option value="北京地铁10号线">北京地铁10号线</option>
<option value="北京地铁11号线">北京地铁11号线</option>
<option value="北京地铁13号线">北京地铁13号线</option>
<option value="北京地铁14号线">北京地铁14号线</option>
<option value="北京地铁15号线">北京地铁15号线</option>
<option value="北京地铁16号线">北京地铁16号线</option>
<option value="北京地铁17号线">北京地铁17号线</option>
<option value="北京地铁19号线">北京地铁19号线</option>
</select><br>
<input style="width:200px;height:50px;font-size: 30px;display: inline-block;color: blue;" type="submit" value="查询    " /><br>
</form>


</div>
<div class="tabs3" id="content3" style="display: none">

<h1>站点查询</h1>
<p>1.输入需要查询站点名称</p>
<form action="newzhandainim.jsp" method="get">
<input type="text" style="width: 180px;height:20px;border-radius:10px" name="zhandian" /><br>
<input style="width:200px;height:50px;font-size: 30px;display: inline-block;color: blue;" type="submit" value="查询    " /><br>
</form>
</div>

<script type="text/jscript">    
document.getElementById("button1").addEventListener("click", function() {  document.getElementById("content1").style.display = "block";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "none";});
document.getElementById("button2").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "block";  document.getElementById("content3").style.display = "none";});
document.getElementById("button3").addEventListener("click", function() {  document.getElementById("content1").style.display = "none";  document.getElementById("content2").style.display = "none";  document.getElementById("content3").style.display = "block";});
</script>
</div>

</body>
</html>
复制代码

 

 

 

 
posted @   超爱彬宝同学  阅读(58)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示