hi michael,
for making a shopping cart you shall have to make use of the session. What i
had done in my shopping cart was adding the elements to the vector and
adding the vector in the session. I have used a bean for setting and getting
the values which he added to the shopping cart. u can find shopping cart
example in so many books and sites on how to do.

Vikramjit Singh,
Systems Engineer,
GTL Ltd.
Ph. 7612929-3140


-----Original Message-----
From: Michael [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 12, 2001 3:19 PM
To: [EMAIL PROTECTED]
Subject: Advanced programmers: How can I add cart functionality to this
page?


The code is below.
I've successfully coded a  repeating-record detail page with pull-down sort
boxes. Though the page works perfectly, I need to add cart functionality,
and would like to keep it simple. I would simply like to have clients view
the repeating details, sort the records, and then select each record desired
to be placed in a cart.

Where do I start???
------------------------------------------------------
Repeating Detail Page: Needs Cart

<%@page language="java" import="java.sql.*"%>
<%@ include file="../Connections/connBeachwear.jsp" %>
<%
String rsBeachwear__varCheckbox = "1";
String rsBeachwear__showCheckbox = "no";
if (request.getParameter ("valueCheckbox")    !=null)
{rsBeachwear__varCheckbox = (String)request.getParameter ("valueCheckbox")
;}
%>
<%
String rsBeachwear__name = "ID";//default sort value
 if (request.getParameter ("order") !=null) {rsBeachwear__name =
(String)request.getParameter ("order");}
String rsBeachwear__sort = "ASC";//default sort value
 if (request.getParameter ("sort") !=null) {rsBeachwear__sort =
(String)request.getParameter ("sort");}

String rsBeachwear__orderby ="ID";//default value
 if (request.getParameter ("order") !=null) {rsBeachwear__orderby =
(String)request.getParameter("order");}
String rsBeachwear__sortby ="ASC";//default value
 if (request.getParameter ("sort") !=null) {rsBeachwear__sortby =
(String)request.getParameter("sort");}

%>
<%
Driver DriverrsBeachwear =
(Driver)Class.forName(MM_connBeachwear_DRIVER).newInstance();
Connection ConnrsBeachwear =
DriverManager.getConnection(MM_connBeachwear_STRING,MM_connBeachwear_USERNAM
E,MM_connBeachwear_PASSWORD);
String chkValues[]=request.getParameterValues("valueCheckbox");
StringBuffer prepStr=new StringBuffer("SELECT ID, Item, Color, Size FROM
Beachwear WHERE ID=");
for(int x = 0; x < chkValues.length; ++x) {
 prepStr.append(chkValues[x]);
 if((x+1)<chkValues.length){
  prepStr.append(" OR ID=");
  }//end if
 }//end for loop
 prepStr.append(" ORDER BY " + rsBeachwear__name + " " + rsBeachwear__sort
);
PreparedStatement
StatementrsBeachwear=ConnrsBeachwear.prepareStatement(prepStr.toString());
ResultSet rsBeachwear = StatementrsBeachwear.executeQuery();
Object rsBeachwear_data;
%>
<title>Beachwear Title</title>
<body bgcolor="#FFFFFF">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><br>
  INVOICE<br>
</p>
<%//FORM "GET" METHOD<%>
<form name="form1" method="get" action="Invoice.jsp">
  <p align="center">
  </p>
  <%while(rsBeachwear.next()){  ;  %>
  <table width="75%" border="1">
    <tr>
      <td width="8%">ID:</td>
      <td width="69%"><%=(((rsBeachwear_data =
rsBeachwear.getObject("ID"))==null ||
rsBeachwear.wasNull())?"":rsBeachwear_data)%></td>
      <td width="23%">
        </div>
      </td>
    </tr>
    <tr>
      <td width="8%">ITEM:</td>
      <td colspan="2"><%=(((rsBeachwear_data =
rsBeachwear.getObject("Item"))==null ||
rsBeachwear.wasNull())?"":rsBeachwear_data)%></td>
    </tr>
    <tr>
      <td width="8%">COLOR:</td>
      <td colspan="2"><%=(((rsBeachwear_data =
rsBeachwear.getObject("Color"))==null ||
rsBeachwear.wasNull())?"":rsBeachwear_data)%></td>
    </tr>
    <tr>
      <td width="8%">SIZE:</td>
      <td colspan="2"><%=(((rsBeachwear_data =
rsBeachwear.getObject("Size"))==null ||
rsBeachwear.wasNull())?"":rsBeachwear_data)%></td>
    </tr>
    <%
  <tr>
      <td width="8%">&nbsp;</td>
      <td colspan="2">

        <input type="checkbox" name="valueCheckbox"
value="<%=(((rsBeachwear_data = rsBeachwear.getObject("ID"))==null ||
rsBeachwear.wasNull())?"":rsBeachwear_data)%>" checked>
 </td>
    </tr>
   </table>
  <%
  }
  %>
  <p>&nbsp; </p>
  <br>
  <table width="54%" border="1">
    <tr>
      <td width="29%">
        <div align="center">Parameter </div>
      </td>
      <td width="28%">
        <div align="center">1</div>
      </td>
      <td width="43%">
        <div align="center">2</div>
      </td>
    </tr>

    <tr>
      <td width="29%">
        <div align="center">
          <input type="submit" value="Sort Now">
        </div>
      </td>
      <td width="28%">
        <div align="center">
    <select name="order" size="1">
     <option value="ID" <% if (rsBeachwear__orderby.equals("ID"))
{out.print("selected"); } %> >ID</option>
   <option value="Item" <% if (rsBeachwear__orderby.equals("Item"))
{out.print("selected"); } %> >Item</option>
   <option value="Color" <% if (rsBeachwear__orderby.equals("Color"))
{out.print("selected"); } %> >Color</option>
   <option value="Size" <% if (rsBeachwear__orderby.equals("Size"))
{out.print("selected"); } %> >Size</option>
          </select>
        </div>
      </td>
      <td width="43%">
        <div align="center">
          <select name="sort" size="1">
            <option value="ASC" <% if (rsBeachwear__sortby.equals("ASC"))
{out.print("selected"); } %>>Ascending</option>
   <option value="DESC" <% if (rsBeachwear__sortby.equals("DESC"))
{out.print("selected"); } %>>Descending</option>
          </select>
        </div>
      </td>
    </tr>
  </table>
  </form>
<%
rsBeachwear.close();
ConnrsBeachwear.close();
%>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to