I have a jsp page which has a "submit" button next to the "Item Url" which can be directed to another jsp page. It will look like below:
|Item1 | Item Url_1 | "Submit Button" for line 1 |Item2| Item Url_2 | "Submit Button" for line 2
I am attaching part of my code which generates the items with the "submit" buttons. How can I pass the Item which corresponds to the respective Item number?
Thanks
<%@ page language="java" import="java.sql.*"%>
<html>
<body bgcolor="pink">
<h2>Stage 2</h2>
<h3>Product URL List</h3>
<form action="frame4A.jsp" name="myform" target=frame4 method="POST">
<%
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
out.println("<h1>Driver not found:" + e + e.getMessage() + "</h1>" );
}
try {
Connection conn = DriverManager.getConnection (
"jdbc:postgresql://*****/****",
"postgres", "*****" );
Statement stmt = conn.createStatement();
ResultSet rs;
rs = stmt.executeQuery("select laptopname, laptopurl from selectedproduct ");
out.println( "<table border=1>" );
while ( rs.next() ) {
String lName= rs.getString("laptopname");
String laptopUrl = rs.getString("laptopurl");
out.println("<tr><td>"+lName+"</td><td><a href="+laptopUrl+" target=\"_new\">"+laptopUrl+"</a></td><td><input type=\"submit\" name=\"reviewItem\" value=\"Reviews\"></td></tr>");
}
out.println( "</table>" );
conn.close();
} catch (Exception e) {
out.println( "<h1>exception: "+e+e.getMessage()+"</h1>" );
}
finally{
}
%>
</form>
</body>
</html>
If I identified your problem correctly, you can handle this in many ways such as
"<input type='button' onclick='handle(" + itemid + ")'>"
Then write a JavaScript function called handle()
function handle(id){
//proceed to submit the form
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.