SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Pedantic Semantic blain's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Coding quality on shopping cart

    Can anyone improve on the quality of this code?

    Code HTML4Strict:
    <table class="cart" cellspacing="0" summary="Shopping Basket">
    <tr class="cart_headings">
        <th class="cart_item">Item</th>
        <th class="cart_price">Price</th>
        <th class="cart_quantity">Quantity</th>
        <th class="cart_total">Total</th>
    </tr>
    <tr class="product">
        <td class="product_name">Flat Screen Compact Computer Station </td>
            <td class="product_price">&pound;302.85</td>
        <td class="product_quantity"><input class="cart_input_quantity" type="text" name="updq_3" value="3"></td>
        <td class="product_total_price">&pound;908.55</td>
    </tr>
    <tr class="product">
        <td class="product_name">test </td>
        <td class="product_price">&pound;10.00</td>
        <td class="product_quantity"><input class="cart_input_quantity" type="text" name="updq_5" value="1"></td>
            <td class="product_total_price">&pound;10.00</td>
    </tr>
    <tr>
        <td colspan="3" class="right_align"><input type="submit" class="cart_update_quantity" name="a" value="Update Quantities"></td>
        <td>&nbsp;</tr>
    </tr>
    <tr>
        <th colspan="3" class="cart_subtotal">Subtotal:</th>
        <td>&pound;918.55</td>
    </tr>
    <tr>
        <th colspan="3" class="cart_vat">VAT:</th>
        <td>&pound;160.75</td>
    </tr>
    <tr>
        <th colspan="3" class="cart_grandtotal">Total:</th>
        <td>&pound;1079.30</td>
    </tr>
    </table>
    Technology is dominated by two types of people:
    those who understand what they do not manage,
    and those who manage what they do not understand.

  2. #2
    SitePoint Addict dgroves's Avatar
    Join Date
    Jan 2007
    Location
    Bath, UK
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can help you, but only if you put in a screenshot of the final result so I can visualize what we are working towards. Do that and I will give you some plentiful advice and help

  3. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is actually pretty clean code for tables,
    and it is Tabular Data, You don't really have to change it to Div's if you were considering it. (IMO)

    If you wanted it to look cleaner you could remove a lot of classes and compile them into CSS.

    <tr class="cart_headings">
    <th>Item</th>
    <th>Price</th>
    <th>Quantity</th>
    <th>Total</th>
    </tr>

    CSS for Cart Heading (If they are all the same)

    .cart_headings {
    font: 14px arial, sans-serif;
    font-weight: bold;
    }

  4. #4
    SitePoint Addict dgroves's Avatar
    Join Date
    Jan 2007
    Location
    Bath, UK
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thinking about it now, I suppose that you are right really, their is not much that can really be done.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    i agree, there is nothing wrong with using html TABLE tags if you have tabular data

    the one-class-per-column-type definitely has to go, though

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Addict dgroves's Avatar
    Join Date
    Jan 2007
    Location
    Bath, UK
    Posts
    364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    the one-class-per-column-type definitely has to go, though
    Absolutely

  7. #7
    Pedantic Semantic blain's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The reason I added a class to each column is to increase semantics, it also means that I can easily style parts of the shopping cart, surely that can't be a bad thing?

    When I spoke of improving the code, I was mainly wanting to address any accessibility or usability issues.
    Technology is dominated by two types of people:
    those who understand what they do not manage,
    and those who manage what they do not understand.

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    i'll let others comment on whether styling individual elements via classes is a good thing, but as far as i know it does not increase semantics

    if you wanted to address accessibility or usability issues, you might have mentioned this in your original post

    i thought you want improved "quality of code"
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    Pedantic Semantic blain's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if I wasn't clear Rudy.

    I always consider that code quality/accessibility/usability all go hand in hand.
    Technology is dominated by two types of people:
    those who understand what they do not manage,
    and those who manage what they do not understand.


Tags for this Thread

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
  •