using html list elements with switch stament and b

2019-09-14 22:56发布

hi i want to know how to get html element and use them with switch statements.

<div id="hori">
<ul>
 <li><a href="#">Aerospace</a></li>
 <li><a href="#">Automotive</a></li>
  <li><a href="#">Energy</a></li>
  <li><a href="#">IC Engines</a></li>
   <li><a href="#">IT</a></li>
   <li><a href="#">Training</a></li>
  <li><a href="#">Wind</a></li>
  <li><a href="#">Turbo</a></li>
 </ul>
</div>

<div id="verti">
<ul>
<li><a href="#1">Internal</a></li>
<li><a href="#2">Demos</a></li>
<li><a href="#3">Best Practice</a></li>
<li><a href="#4">Marketing</a></li>
<li><a href="#5">Papers & Public</a></li>
<li><a href="#6">Validation</a></li>
<li><a href="#7">Training</a></li>
</ul>
</div>

here the horizontal and vertical menus will be in the same page.the vertical menus is same for all horizontal menus for example.hori-main menus verti:sub menus.

  1. aerospace:
    • internal
    • demo
  2. automotive:
    • internal
    • demo

if the user click any of the main menus the mode should be changed accordingly. if i click internal under aerospace,related table should be displayed in the same page without postback.

here is my jsp page which will display a html table binded with database

Class.forName("com.mysql.jdbc.Driver").newInstance();

 connection = DriverManager.getConnection(connectionURL, "root", "root");

 java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());

  psmnt1 = connection.prepareStatement("insert into file12(id,file_path,file_date) values(?,?,'"+ sqlDate+"')");

 psmnt1.setString(1, concat);

  psmnt1.setString(2, f.getPath());


  psmnt=connection.prepareStatement("select * from file12");

  rs=psmnt.executeQuery();

 int s=psmnt1.executeUpdate();
if(s>0)
{
System.out.println("Uploaded successfully !");
}
else
{
System.out.println("Error!");
}
}

catch(Exception e)
{
out.print("-----------error--------------"+e);
}
%>
<table cellpadding="15" border="1">
<%
 while(rs.next()){
%>
<tr>
<td><%=rs.getString(1)%> </td>
<td><%=rs.getString(2)%> </td>
<td><%=rs.getString(3)%> </td>
</tr>
<%}%>
</table>

1条回答
Animai°情兽
2楼-- · 2019-09-14 23:35

if the user click any of the main menus the mode should be changed accordingly. if i click internal under aerospace,related table should be displayed in the same page without postback.

Without postback it's not possible, jsp is not asp , in jsp there is nothing like postback. Try some other strategy to achieve the required functionality(like ajax)

查看更多
登录 后发表回答