Results 1 to 3 of 3

Thread: Please HElp Me!!! Thanks... Urgent...

  1. #1
    Join Date
    Jun 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please HElp Me!!! Thanks... Urgent...

    Hi guys!!! Need your help urgently. Need to present later... Thanks a lot.\
    <!-- Filename: ShoppingCart.jsp original version -->
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="java.util.*" %>

    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="database.ShoppingCart" />
    <%
    String id = request.getParameter("itemID");
    String buttonPressed = request.getParameter("Submit");
    String updatePressed = request.getParameter("input");
    String quantity = request.getParameter("Sum");

    if(id!=null){
    if (updatePressed!=null){
    cart.updateQuantity(id, Integer.parseInt(quantity));
    }

    if (buttonPressed!=null){

    cart.removeItem(id);
    }
    }

    %>

    <html>
    <head>
    <title>Shopping Cart Contents</title>
    </head>
    <body>
    <center>
    <table width="300" border="1" cellspacing="0"
    cellpadding="2" border="0">
    <caption><b>Shopping Cart Contents</b></caption>
    <body bgcolor= #CCCFFFF>
    <tr>
    <th>Description</th>
    <th>Price</th>
    <th>Quantity</th>
    <th>Remove An Item</th>
    <th>Update Quantity</th>
    </tr>
    <TR>

    <%
    Enumeration enum = cart.getEnumeration();
    String[] tmpItem;
    int numOfItems = 0;
    // Iterate over the cart
    while (enum.hasMoreElements()) {
    %>
    <form action="ShoppingCart.jsp" method="post">
    <%
    tmpItem = (String[])enum.nextElement();
    numOfItems += Integer.parseInt(tmpItem[3]);
    %>
    <tr>
    <td><%=tmpItem[1] %></td>
    <td align="center">$<%=tmpItem[2] %></td>
    <td align="center"><%=tmpItem[3] %></td>
    <td><input type="submit" name="Submit" value="Remove"></td>
    <td><input type="text" name="Sum"><input type="Submit" name="input" value="update"></td>
    <input type="hidden" name="itemID" value= "<%=tmpItem[0] %>" >
    </form>
    </tr>

    <%
    }

    %>
    </table>
    </font><font color = "#000FFF">
    <br> You are buying <%=cart.getNumOfItems() %> items.</br>
    <br> Total coat is $<%=cart.getCost() %> </br>
    <p align = "center">You have to pay $<%=cart.getCost() %>
    </font><font color = "#CC0099">
    </center>
    <a href="AddToShoppingCart.jsp">Back to Catalog</a>

    </body>
    </html>
    Can tell me briefly wat does this means specially those in bold cox dun understand...

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please post in the correct cateogry. From what I can tell this is JSP (definitely not HTML either way). Moving thread to Other Category, since we don't have a JSP forum yet.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <%
    Enumeration enum = cart.getEnumeration(); // Enumeration: an object which assigns each item a number.  cart.getEnumeration() can be expected to return an enumeration consisting of all the items in the cart.
    String[] tmpItem; // Array of Strings
    int numOfItems = 0;
    // Iterate over the cart
    while (enum.hasMoreElements()) { // As long as we haven't reached the last item,
    %>
    <form action="ShoppingCart.jsp" method="post"> // open a form,
    <%
    tmpItem = (String[])enum.nextElement(); // assign the next element of enum to tmpItem, casting it into an array of Strings first,
    numOfItems += Integer.parseInt(tmpItem[3]); // then increase the total number of items by the integer stored in the third string in the String array (presumably quantity).
    %>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •