Advertisement
Guest User

Untitled

a guest
Oct 28th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2. <%@page import="java.sql.*"%>
  3. <%@ page import = "java.io.*,java.util.*, javax.servlet.*" %>
  4. <%@ page import ="java.text.SimpleDateFormat"%>
  5. <%@ page import = "java.util.Date"%>
  6.  
  7. <!DOCTYPE html>
  8.  
  9. <html>
  10. <head>
  11. <meta http-equiv="refresh" content="10" content="text/html; charset=UTF-8">
  12. <%
  13. //Grabs the username and Client id if the user has logged in
  14. String usernames=(String)session.getAttribute("username");
  15. String cid=(String)session.getAttribute("ClientID");%>
  16. <p>Username: <%=usernames%></p>
  17. <p>CID: <%=cid%></p>
  18.  
  19. <title>Bidding</title>
  20. <link href="" type="text/css" rel="stylesheet">
  21. <style>
  22. table, th, td {
  23. border: 1px solid black;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <form>
  29. <h1>Search Cars</h1>
  30. </p>
  31.  
  32. <table class="table table-bordered table-striped" style="width: 90%">
  33. <tr>
  34. <th>Selected</th>
  35. <th>Image</th>
  36. <th>Car Make</th>
  37. <th>Car Model</th>
  38. <th>Car Description</th>
  39. <th>Start Date</th>
  40. <th>End Date</th>
  41. </tr><%
  42.  
  43. //Grabs the ProductID from previous page
  44. String pid=request.getParameter("pid");
  45. String edate = null;
  46.  
  47. //if username is null: aka not logged in then ...Don't allow submit button
  48. if(usernames==null){
  49. // response.sendRedirect("index.html");
  50. }
  51.  
  52. //todays = current date and time. endDate = db enddate and tiame
  53. Date today = new Date();
  54. Date endDate = new Date();
  55. SimpleDateFormat sdfToday = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
  56.  
  57.  
  58.  
  59. try{
  60. //Loads the DB and loads the selected Product ID
  61. Class.forName("com.mysql.jdbc.Driver").newInstance();
  62. Connection con= DriverManager.getConnection("jdbc:mysql://localhost/auction","root","cenk");
  63. Statement st= con.createStatement();
  64. ResultSet rs=st.executeQuery("Select * from auction_items where ProductID='"+pid+"'" );
  65. while(rs.next()){
  66. %>
  67. <tr>
  68. <td><input type="radio" name="pid" id="pid" checked="checked" value ="<%=rs.getInt("ProductID")%>" </input></td>
  69. <td><%=rs.getString("images")%></td>
  70. <td><%=rs.getString("cartype")%></td>
  71. <td><%=rs.getString("carmodel")%></td>
  72. <td><%=rs.getString("cardetails")%></td>
  73. <td><%=rs.getString("startDate")%></td>
  74. <td><%=rs.getString("enddate")%></td>
  75. <% edate =rs.getString("endDate");%>
  76. </tr>
  77. <%
  78. }
  79. %></table>
  80.  
  81.  
  82. <%
  83. }
  84. catch(Exception e){
  85. e.printStackTrace();
  86. }
  87.  
  88.  
  89. int prodID=0;
  90. double cost=0;
  91. double userinput=0;
  92.  
  93. // Date date2 = sdfToday.parse(edate);
  94.  
  95. //Loads the DB and Finds the Cost. If cost is Null then default price $100
  96. Connection con= DriverManager.getConnection("jdbc:mysql://localhost/auction","root","cenk");
  97. Statement st= con.createStatement();
  98. ResultSet rs=st.executeQuery("Select * from auction_items where ProductID='"+pid+"'" );
  99. rs=st.executeQuery("Select * from orders where pid='"+pid+"'" );
  100. while(rs.next()){
  101. prodID=rs.getInt("pid");
  102. cost=rs.getDouble("cost");
  103. }
  104. //if(prodID==0)
  105. // cost=100;
  106.  
  107. //NEED THIS TO UPDATE WHEN SUBMIT BUTTON IS PRESSED
  108. //When submit is click the page needs to refresh and the variables need to be updated
  109.  
  110.  
  111. %>
  112. <br>
  113. $<input type="text" name="currentbid" id="currentbid" value="<%=cost%>" readonly><br>
  114. $<input type="text" name="livebid" id="livebid" value="<%=userinput%>" min="<%=cost%>"><br><br>
  115.  
  116. </p>
  117.  
  118. <%
  119. if(userinput>cost)
  120. cost=userinput;
  121. %>
  122. product id: <%=pid%> cost <%=cost%><p>
  123. user input: <%=userinput%>
  124.  
  125. <!--Grabs current Date and time-->
  126. <script type="text/javascript">
  127. function display_c(){
  128. var refresh=1000; // Refresh rate in milli seconds
  129. mytime=setTimeout('display_ct()',refresh)
  130. }
  131.  
  132. function display_ct() {
  133. var x = new Date()
  134. document.getElementById("<%=today%>").innerHTML = x;
  135. display_c();
  136. }
  137.  
  138.  
  139. var livebid = document.getElementById('livebid')
  140. var currentbid = document.getElementById('currentbid')
  141.  
  142. if(livebid>currentbid){
  143. currentbid=livebid;
  144. }
  145.  
  146. </script>
  147.  
  148. <body onload=display_ct();>
  149. <div id="test"><span></span><div>
  150.  
  151. <%
  152.  
  153.  
  154. /*
  155. if(today.after(date2)){
  156. //update the query and change the status to expired
  157.  
  158. %> Its over <%
  159. } else{
  160. //update teh query and add
  161.  
  162. %> You still have time to purchase<%
  163. }
  164. */
  165. %>
  166. <td><span id="pid" value ="<%=pid%>" </span></td>
  167.  
  168. <input type="submit" onclick="bidding.jsp">
  169.  
  170. <script>
  171. function update() {
  172. var x = document.getElementById("userinput");
  173. x= 500;
  174. }
  175. </script>
  176.  
  177. </form>
  178.  
  179. </center>
  180. </body>
  181. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement