VideoHelp Forum




+ Reply to Thread
Results 1 to 17 of 17
  1. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    I'm trying to create a single HTML page with a single ASP file. I want to make a primitive version of a shopping cart.

    NOTE: This is precisely what I want, so please don't suggest some service or "other way" of doing it. I merely need some help with the code part of the equation, I know it can be done, and it's probably not all that hard for somebody familiar with ASP coding.

    Look at this:


    The form is very simple. It is a series of items for sale, each with two options (for the sake of example, one is standard, one is premium). It uses 3 radio buttons to select one of the two option, or a "non-option". I would be open to checkboxes too, whatever works best.

    Now then, when you select an item, the TOTAL PRICE at the bottom of the page updates with your new total. For the sake of simplicity, shipping is included in the option pricing.

    After a person has selected their merchandise, the last thing on the page is a form where they can fill in their shipping information.

    You'll then click a SUBMIT button of some kind, and a CDONTS ASP object will send me an e-mail, showing what was ordered, as well as the shipping information.

    Like so:
    Code:
    ORDER:
    ITEM ONE - OPTION1 $50
    ITEM TWO - OPTION2 $100
    
    TOTAL: $150
    
    SHIPPING ADDRESS:
    NAME: JOHNQ CUSTOMER
    STREET1
    STREET2
    CITY 
    STATE 
    ZIP/POSTAL
    COUNTRY
    The response message after you click submit will have some more information on it, it's an HTML page, with links and other needed items. Payment will be worried about later. This is ONLY an order submission system. I do not need nor want an integrated payment system.

    Any ideas?

    This is the code I have at the moment, something I saw elsewhere. I can probably edit it all on my own, but at the moment, it's a bit of a struggle.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd">
    
    <html lang="en" dir="ltr">
    <head>
      <title>Order form</title>
    
      <style type="text/css">
        @media screen {
          body {
            font: 100% sans-serif;
          }
          h1 {
            font: 130% normal sans-serif;
            text-align: center;
          }
          fieldset {
            border-style: none;
            margin: 0 0 1em;
            padding: 0.5ex;
          }
          label {
            display: block;
            margin-left: 1em;
            width: 12em;
          }
          legend {
            font-weight: bold;
            margin: 0;
            padding: 0;
          }
          #order {
            position: relative;
          }
          #total {
            display: block;
            margin-left: auto;
            margin-right: auto;
            width: 6em;
          }
          #total-group {
            border-style: none;
            text-align: center;
            position: fixed;
            right: 10%;
            top: 20%;
            width: 8em;
          }
          #total-group legend {
            display: none;
          }
          #total-label {
            margin-bottom: 0.75em;
            margin-left: 0;
            width: auto;
          }
        }
      </style>
    </head>
    
    <body>
      <h1>Computer A</h1>
      <form id="order" action="" method="post">
      <fieldset><legend>Processor</legend>
        <label><input name="processor" type="radio" value="0" checked>
        Default option</label>
        <label><input name="processor" type="radio" value="50">
        Upgrade 1 ($50.00)</label>
        <label><input name="processor" type="radio" value="100">
        Upgrade 2 ($100.00)</label>
      </fieldset>
      <fieldset><legend>Memory</legend>
        <label><input name="memory" type="radio" value="0" checked>
        Default option</label>
        <label><input name="memory" type="radio" value="50">
        Upgrade 1 ($50.00)</label>
        <label><input name="memory" type="radio" value="100">
        Upgrade 2 ($100.00)</label>
      </fieldset>
      <fieldset><legend>Hard Drive</legend>
        <label><input name="hard-drive" type="radio" value="0" checked>
        Default option</label>
        <label><input name="hard-drive" type="radio" value="50">
        Upgrade 1 ($50.00)</label>
        <label><input name="hard-drive" type="radio" value="100">
        Upgrade 2 ($100.00)</label>
      </fieldset>
      <fieldset id="total-group"><legend>Total</legend>
        <label id="total-label">Your total:
        <input id="total" type="text" value="$0.00"></label>
        <input type="submit" value="Send">
        <input type="reset" value="Reset">
      </fieldset>
      </form>
      <script type="text/javascript">
        Number.prototype.toCurrency = function(c, t, d) {
          var n = +this,
              s = (0 > n) ? '-' : '',
              m = String(Math.round(Math.abs(n))),
              i = '',
              j, f;
              c = c || '';
              t = t || '';
              d = d || '.';
    
          while (m.length < 3) {m = '0' + m;}
          f = m.substring((j = m.length - 2));
          while (j > 3) {i = t + m.substring(j - 3, j) + i; j -= 3;}
          i = m.substring(0, j) + i;
          return s + c + i + d + f;
        };
    
        if(document.getElementsByName) {
          (function() {
            var E = document.forms.order.elements,
                T = E.total;
    
            function calculateTotal() {
              var t = 0,
                  e, v;
    
              if((e = getChecked('processor', this.form, 'radio'))) {t += +e.value;}
              if((e = getChecked('memory', this.form, 'radio'))) {t += +e.value;}
              if((e = getChecked('hard-drive', this.form, 'radio'))) {t += +e.
    
    value;}
    
              T.value = (t * 100).toCurrency('$');
            }
            function getChecked(gN, f, t) {
              var g = document.getElementsByName(gN);
                  t = t || 'checkbox';
    
              for(var i = 0, n = g.length, c; i < n; ++i) {
                if((t == (c = g[i]).type) && c.checked && (f == c.form)) {return c;}
              }
            }
    
            for(var i = 0, n = E.length; i < n; ++i) {
              if('radio' == E[i].type) {
                E[i].onchange = calculateTotal;
              }
            }
            E = null;
          })();
        }
      </script>
    </body>
    </html>
    And that's just a start on the HTML. I've still got to work on the ASP portion, where I grab all the variables and have them sent.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  2. Greetings Supreme2k's Avatar
    Join Date
    Feb 2003
    Location
    Right Here, Right Now
    Search Comp PM
    I suggest going here:
    http://www.asp101.com/samples/shopping.asp

    Sometimes there's stuff out there that you can tweak to suit your needs.

    If that's not what you want, check out this one:
    http://data.ul.com/pagos/subscrib.asp

    I created it roughly 8 years ago, but it still works okay (email notification among other things). Funny that they haven't updated it in all that time (I've been gone from UL about 4 years).

    If you want it, I have the original code that you can tweak to your liking.
    Quote Quote  
  3. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Thanks supreme, but that's just way out of my league. I don't know how to edit it very well. That sample is several pages and turns to garbage if I try to edit.

    It's time like these that I hate the Internet for having too much info. I'm sure this sort of simple code I seek existed at some point, I remember using it in the past on sites, but serach engine results trying to find something like this are just complex codes or people trying to sell you complex scripts. Sucks.

    ASP scripting for dummies. But I don't want to read a huge book, I only seek a few things.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  4. VH Veteran jimmalenko's Avatar
    Join Date
    Aug 2003
    Location
    Down under
    Search PM
    LS, your code as it stands doesn't work. The first time you click on a radio button, the total is not updated. I suspect that it's because on your first onchange event you initialise the array for storing the values of the radio buttons, such that it only starts adding on subsequent attempts after that.


    I don't mean to be rude, but I would suggest that if "your way" is the only way you'll do this, you might need to pay someone to do it for you. That first example S2K put up (the example from ASP101) should be reasonably easy to customise - it is quite easy to change the "look", but it's more the functionality which you want to stay the same or similar.
    If in doubt, Google it.
    Quote Quote  
  5. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Originally Posted by jimmalenko
    LS, your code as it stands doesn't work. The first time you click on a radio button, the total is not updated. I suspect that it's because on your first onchange event you initialise the array for storing the values of the radio buttons, such that it only starts adding on subsequent attempts after that.

    I don't mean to be rude, but I would suggest that if "your way" is the only way you'll do this, you might need to pay someone to do it for you. That first example S2K put up (the example from ASP101) should be reasonably easy to customise - it is quite easy to change the "look", but it's more the functionality which you want to stay the same or similar.
    Yeah, I didn't write that code, but you're correct, it's broken. I hate JS anyway. It doesn't even have to actively update, I would be happy with a button you press down the page that says "calculate" and gives a total (without page reload, preferably).

    I cannot pay anybody. I'm already not making money on the endeavor this is to be used on (services to a non-profit, I make next to nothing on it). Not to mention I give out so much free video advice, I don't feel it's too much to ask for a little bit of programming help. Hoping karma will work for once.

    That ASP101 code is missing the entire database structure, so there's no way to work with it, seeing how the access DB is not shown. They even mention the code they give is probably not going to be of any use to anybody for this reason and more.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  6. VH Veteran jimmalenko's Avatar
    Join Date
    Aug 2003
    Location
    Down under
    Search PM
    If you're happy with something that looks like the image you supplied, but has a "calculate now" button instead, I can write you a page in ASP that doesn't use javascript at all.
    If in doubt, Google it.
    Quote Quote  
  7. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    I tried yesterday to write out the HTML form of what I wanted. My skills and knowledge of forms is to make a HTML form, and then behind the scenes feed the form info to an ASP file to process the data. So that's what I attempted to do.

    This is what I wanted the form to look like: http://www.lordsmurf.com/temp/orderform.gif
    Messed up HTML code is here: http://www.lordsmurf.com/temp/index.htm

    Some of the code is just placeholder info, was aiming for the look and feel mostly. I could not get the page to load correctly, all I could accomplish is the look and feel in the editor.

    The name of the form will be index.htm or default.asp (the basic page when the directory is called). And then the preferred name of the external asp form (if one gets used) would be placeorder.asp

    I had planned on using basic CDONTS sendmail ASP form for sending the e-mail to me, as that's what I know how to do.

    Adding a calculator and the radio selections is what really just blows me away. This is outside of my skill level right now, at least trying to do it from scratch. It would be different if I had something I could edit and then alter.

    The calculator would preferably be one that does not incur a page reload, or if it does, the cache doesn't expire and lose the selections after reload.

    I would be grateful for any help on this. Even if I get 2-3 people helping me on just one piece of the puzzle, it all adds up.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  8. Greetings Supreme2k's Avatar
    Join Date
    Feb 2003
    Location
    Right Here, Right Now
    Search Comp PM
    Did you get my PM? Do you need databse connections?
    Quote Quote  
  9. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Originally Posted by Supreme2k
    Did you get my PM? Do you need databse connections?
    I did. But as jimmalenko pointed out, the JS in the file I originally put up as an example (something I found elsewhere online) is flawed and doesn't work right. I'm still trying to wrap my head around the ASP code and other stuff you gave me, it may take a few days to see what's going on there.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  10. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    I quit. **** it.
    Ad rotation more important.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  11. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM

    Quote Quote  
  12. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Have you got one of a Smurf smashing a keyboard?
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  13. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    I found something in PHP that I was able to edit and tested out great last night.

    http://www.dyn-web.com/scripts/orderform/

    and then altered it to function a lot like their form:
    http://www.dyn-web.com/bus/prices.php

    Editing and adding to the PHP code was really not all that difficult, as the code to start from was clean and had a lot of notations made to describe it. They apparently designed it for easy updates.

    So thanks for those that tried to help.

    And I didn't have to give up after all.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  14. Greetings Supreme2k's Avatar
    Join Date
    Feb 2003
    Location
    Right Here, Right Now
    Search Comp PM
    Actually, we could have done more if you would have said that PHP was acceptable (available) from the start.

    Kind of like where I used to work. They wanted pages written in Cold Fusion. So after learning CF, I actually got a peek at the server and found that it had php, asp, IIS, mysql and apache available. Their explanation: "Nobody asked." Me:"Not only asked but suggested, pleaded, and demanded!"
    Quote Quote  
  15. Video Restorer lordsmurf's Avatar
    Join Date
    Jun 2003
    Location
    dFAQ.us/lordsmurf
    Search Comp PM
    Most PHP I've ever seen was harder than ASP. So I just wanted to work with ASP more since I somewhat know it. And more people seem to know ASP than PHP.

    I can run PHP, ASP, CF, CGI, Perl.
    Cannot run ASP.NET.

    No MySQL.
    Only MS Access ODBC.

    But this project has proven that PHP is only as hard as the coder makes it. Which now makes me wonder why so many PHP writers have code that looks as complex as the human genome.
    Want my help? Ask here! (not via PM!)
    FAQs: Best Blank DiscsBest TBCsBest VCRs for captureRestore VHS
    Quote Quote  
  16. Greetings Supreme2k's Avatar
    Join Date
    Feb 2003
    Location
    Right Here, Right Now
    Search Comp PM
    True. Same with javascript. Some pages have 3 external js files that do the work of about 10 or so lines of code.

    I've seen people do stuff in ASP like open and close a database for every piece of data that they pop in (open, first name, close, open, last name, close, etc) so much that my head has nearly exploded.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!