Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@page import="java.sql.*"%>
- <%@ page import = "java.io.*,java.util.*, javax.servlet.*" %>
- <%@ page import ="java.text.SimpleDateFormat"%>
- <%@ page import = "java.util.Date"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="refresh" content="10" content="text/html; charset=UTF-8">
- <%
- //Grabs the username and Client id if the user has logged in
- String usernames=(String)session.getAttribute("username");
- String cid=(String)session.getAttribute("ClientID");%>
- <p>Username: <%=usernames%></p>
- <p>CID: <%=cid%></p>
- <title>Bidding</title>
- <link href="" type="text/css" rel="stylesheet">
- <style>
- table, th, td {
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <form>
- <h1>Search Cars</h1>
- </p>
- <table class="table table-bordered table-striped" style="width: 90%">
- <tr>
- <th>Selected</th>
- <th>Image</th>
- <th>Car Make</th>
- <th>Car Model</th>
- <th>Car Description</th>
- <th>Start Date</th>
- <th>End Date</th>
- </tr><%
- //Grabs the ProductID from previous page
- String pid=request.getParameter("pid");
- String edate = null;
- //if username is null: aka not logged in then ...Don't allow submit button
- if(usernames==null){
- // response.sendRedirect("index.html");
- }
- //todays = current date and time. endDate = db enddate and tiame
- Date today = new Date();
- Date endDate = new Date();
- SimpleDateFormat sdfToday = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- try{
- //Loads the DB and loads the selected Product ID
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- Connection con= DriverManager.getConnection("jdbc:mysql://localhost/auction","root","cenk");
- Statement st= con.createStatement();
- ResultSet rs=st.executeQuery("Select * from auction_items where ProductID='"+pid+"'" );
- while(rs.next()){
- %>
- <tr>
- <td><input type="radio" name="pid" id="pid" checked="checked" value ="<%=rs.getInt("ProductID")%>" </input></td>
- <td><%=rs.getString("images")%></td>
- <td><%=rs.getString("cartype")%></td>
- <td><%=rs.getString("carmodel")%></td>
- <td><%=rs.getString("cardetails")%></td>
- <td><%=rs.getString("startDate")%></td>
- <td><%=rs.getString("enddate")%></td>
- <% edate =rs.getString("endDate");%>
- </tr>
- <%
- }
- %></table>
- <%
- }
- catch(Exception e){
- e.printStackTrace();
- }
- int prodID=0;
- double cost=0;
- double userinput=0;
- // Date date2 = sdfToday.parse(edate);
- //Loads the DB and Finds the Cost. If cost is Null then default price $100
- Connection con= DriverManager.getConnection("jdbc:mysql://localhost/auction","root","cenk");
- Statement st= con.createStatement();
- ResultSet rs=st.executeQuery("Select * from auction_items where ProductID='"+pid+"'" );
- rs=st.executeQuery("Select * from orders where pid='"+pid+"'" );
- while(rs.next()){
- prodID=rs.getInt("pid");
- cost=rs.getDouble("cost");
- }
- //if(prodID==0)
- // cost=100;
- //NEED THIS TO UPDATE WHEN SUBMIT BUTTON IS PRESSED
- //When submit is click the page needs to refresh and the variables need to be updated
- %>
- <br>
- $<input type="text" name="currentbid" id="currentbid" value="<%=cost%>" readonly><br>
- $<input type="text" name="livebid" id="livebid" value="<%=userinput%>" min="<%=cost%>"><br><br>
- </p>
- <%
- if(userinput>cost)
- cost=userinput;
- %>
- product id: <%=pid%> cost <%=cost%><p>
- user input: <%=userinput%>
- <!--Grabs current Date and time-->
- <script type="text/javascript">
- function display_c(){
- var refresh=1000; // Refresh rate in milli seconds
- mytime=setTimeout('display_ct()',refresh)
- }
- function display_ct() {
- var x = new Date()
- document.getElementById("<%=today%>").innerHTML = x;
- display_c();
- }
- var livebid = document.getElementById('livebid')
- var currentbid = document.getElementById('currentbid')
- if(livebid>currentbid){
- currentbid=livebid;
- }
- </script>
- <body onload=display_ct();>
- <div id="test"><span></span><div>
- <%
- /*
- if(today.after(date2)){
- //update the query and change the status to expired
- %> Its over <%
- } else{
- //update teh query and add
- %> You still have time to purchase<%
- }
- */
- %>
- <td><span id="pid" value ="<%=pid%>" </span></td>
- <input type="submit" onclick="bidding.jsp">
- <script>
- function update() {
- var x = document.getElementById("userinput");
- x= 500;
- }
- </script>
- </form>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement