我有两个jsp
个网页。其中一个是searchData.jsp
,另一个是searchResult.jsp
。
searchData.jsp
<form action="searchResult.jsp" method="POST">
<table border="0" width="" cellspacing="15" cellpadding="1">
<thead>
<tr>
<th>Search Using:</th>
<th><select name="search">
<option value="Company_Name">Company Name</option>
<option value="Contact_Person">Contact Person</option>
<option value="Phone">Phone Number</option>
</select></th>
<th>of Category:</th>
<th><select name="category">
<option value="hospital"><bean:message key="select.hospital" /></option>
<option value="company"><bean:message key="select.company" /></option>
<option value="institution"><bean:message key="select.institution" /></option>
<option value="others"><bean:message key="select.other" /></option>
</select></th>
<th><input type="text" name="search_tf" /></th>
<th><input type="submit" value="Search" /></th>
</tr>
</thead>
<tr>
<td></td><td></td><td></td><td></td>
<td><small>(Blank Search will result in Full Search Result)</small></td>
</tr>
</table>
</form>
当我选择公司名称和公司并点击提交时,它将转到searchResult.jsp
并显示但是我的问题是我有30到40条记录,我必须每页放10条记录。所以这里分页是必要的,我尝试使用javascript
和jquery
,但我没有得到正确的分页。这是我的searchResult.jsp
searchResult.jsp
<form method="post" name="form">
<table class="divtable" width="1140">
<div id="divheader">
<thead>
<tr>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Id</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Date & Time</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Company Name</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Contact Person</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Address</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Phone</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Company Email</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Follow Up Action</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Status</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Lead Details</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Lead Value</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Follow Up Date</th>
<th style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Category</th>
<th colspan="2" style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;background: beige;">Action</th>
</tr>
</thead>
</div>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%
Connection con = null;
Object o2 = session.getAttribute("email");
String email = o2.toString();
String category = request.getParameter("category");
String search = request.getParameter("search");
String search_tf = request.getParameter("search_tf");
Statement st, st1;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/marketing_database", "root", "root");
st = con.createStatement();
st1 = con.createStatement();
System.out.println("At SearchResult.jsp:" + email + "," + category + "," + search + "," + search_tf);
ResultSet rs = st.executeQuery("Select Id,Company_name,Contact_Person,Address,Phone,Company_Email,Review,Status,Lead_Date,Lead_Details,Lead_Value,followup_Date,Category from marketing_database.lead where Email = '" + email + "' OR " + search + " LIKE '%" + search_tf + "%' ORDER BY Id;");
String q2 = "update dummy set category='" + category + "' where id = '1';";
st1.executeUpdate(q2); // To insert the category name to dummy table in database
%>
<%
while (rs.next()) {
%>
<tr><td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td1"><%=rs.getString(1)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td3"><%=rs.getString(9)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td2"><%=rs.getString(2)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td3"><%=rs.getString(3)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td4"><%=rs.getString(4)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td5"><%=rs.getString(5)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td6"><%=rs.getString(6)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td7"><%=rs.getString(7)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td8"><%=rs.getString(8)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td9"><%=rs.getString(10)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td10"><%=rs.getString(11)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td11"><%=rs.getString(12)%></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td12"><%=rs.getString(13)%></td>
<td style="padding:1px 5px;border-bottom:1px solid #d47f66;" class="td13"><input type="button" name="edit" value="Edit" style="background-color:#49743D;font-weight:bold;color:#ffffff;" onclick="editRecord(<%= rs.getString(1)%>);" ></td>
<td style="padding:1px 5px;border-right:1px solid #d47f66;border-bottom:1px solid #d47f66;" class="td13"><input type="button" name="delete" value="Delete" style="background-color:#ff0000;font-weight:bold;color:#ffffff;" onclick="deleteRecord(<%= rs.getString(1)%>);" ></td>
<% count++;%>
</tr>
<%
}
%>
<%
} catch (Exception e) {
e.printStackTrace();
}
%>
</table>
</form>