#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I have a small web site that sells cakes (http://www.whiskeycake.com). I need a way to display the total order amount when a customer submits an order. There is only one product and one price, so this would be a very simple calculation (quantity x price + shipping). Any ideas on the best way to accomplish this? Is Javascript a possibility?
    Thanks
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    11
    Rep Power
    0
    I would always discourage using javaScript for essential site features. It may be hard to believe, but there are still people using browsers that don't support javaScript functions properly (AOL being the worst offender). There are also many out there (myself included) who have javaScript disabled, since it is usually only used for pointless time-wasters anyhow. As a business, you don't want to limit your customer base by blocking those people.

    You should look into a CGI script. Since you're still a small operation, the overhead incurred using CGI won't be an issue. Perl does a great job with these things, and you could almost certainly find a script you could adapt.

    Of course, this all assumes you're hosting the site yourself or have a service provider willing to let you run CGI scripts. Many charge a bit extra for this "privalege"

    -Joe
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    Hi,

    There is a example of exactly what you are talking about on http://acky.net/tutorials/javascripts/functions/

    Sincerely,
    Alex Osipov
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    ok first the code.
    in the <head> of your page put:

    <script>
    function addit(){
    if (document.images){
    var tote=document.cake.ordered.value;
    var totecakes = tote * 24.95;
    var carrall = tote * 7.95;
    document.cake.tcakes.value= totecakes;
    document.cake.tcarr.value= carrall;
    }}
    </script>

    give your form a name ie:change this-

    <form method="post" action="/cgi-common/mailmerge.pl">

    to this,

    <form method="post" name="cake" action="/cgi-common/mailmerge.pl">

    then add the result bit - in your existing table wherever you want it:

    <tr><td>Total amount for cakes: $<input type="text" name="tcakes" value="" size="5"></td>
    <td width=50></td>
    <td>Total carriage: $<input type="text" name="tcarr" value="" size="5"></td>
    </tr>

    and then off you go - you have no layers etc so this will work in any javascript enabled browser, .......

    which includes almost all surfers - even the latest version of AOL understands this script, even DIY browsers normally run on the back of IE or NS - even OPERA understands this code.

    I only know of 2 client side scripting languages - one of them is JavaScript the other one isn't.

    Sorry Joe but I can not for the life of me understand why you have javascript turned off, almost all pages have some JS in them somewhere - CGI is great if you do not mind refreshing the page every time you want to add two numbers up????

    I feel that you are giving some pretty dodgy advice on this issue - for more serious coding server side or CGI is fine but for simple validation or mouseovers etc !
    And to turn off JavaScript as it is 'only for time-wasters' - this is daft!

    Simon.



    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    36
    Rep Power
    14
    This may not be the answer you are loking for because it is not a php script. There are some free shopping carts on the net that will serv your purpose. Try one or two they may work for you. In any event you will get an idea of what you realy need before you start trying to write any code. Plus you are taking orders while you are wrighting and testing.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    11
    Rep Power
    0
    Daft or not, the point is I turn it off. Many people I know turn it off, at least part of the time. You need to weigh the risk of blocking out users vs. a quick-fix solution to your problem. If it were my money, I know what I would do.

    I have nothing against JavaScript, it's a fine scripting (not to be confused with programming) language for minor enhancements. My main problem is the fact that there is just so much bad code out there, and bad code does very bad things.

    As for JavaScript support, it really depends upon what you're doing. I've been building very large commercial and entertainment web sites for around 4 years, and I've seen my share of unsupported features (JS and otherwise). AOL is notorious in the development circle as being very strange about it's JavaScript support. But then, we've had to strip out loads of cool toys to accomodate AOL users for years, so I suppose it's not surprising.

    This of course, is my opinion. Certainly the trend these days is to use JS for these things. But then, someone out there also thought that the blink tag would be a good idea... Agggghhh...

    -Joe
  12. #7
  13. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Dr_E_lectric I do not think that Longhorn was looking for a PHP answer , nor a real shopping cart at this point.

    Joe - ok I was a bit harsh maybe - but....

    Where do you draw the line? If you allow for users that
    a)disable javascript
    b)disable cookies
    or worse c)use Mosaic v1 , then as suppliers of interesting content we are buggered.
    Not every client will have access to PHP etc and moving them to different servers etc is not always an option.

    The buzzwords of the day are'compliance' and <smart comment><language>'xml'</language></smart comment>. Leaving aside the latter, as quirky as IE and NS 4+ browsers are, there are workarounds for their problems, both browsers are free to the general public, so who out there can not afford one? both are happy with JavaScript ,Cookies and Layers - one or the other sits on almost every machine connected to the internet.
    I therfore, take V4+ as the lowest common denominator with an assumption that JavaScript is running (have to admit I do not even test for it!<bad/> ).

    I think that most of the surfers who visit my or any pages are using IE or NS4+ untouched apart from turning off cookies because a friend told them that 'cookies can eat up your hard drive'(I have heard this one twice!) ,Although AOL does not quite have the hold here in Oz as it does elsewhere. So I will stick with my theory and hope I am right!.

    Shutting up .......now.

    Simon.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  14. #8
  15. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Forgot to mention

    'But then, someone out there also thought that the blink tag would be a good idea... Agggghhh...'

    can not argue with that one!.


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    London, England
    Posts
    251
    Rep Power
    14
    Choosing a "baseline browser" for your site is important, and rather than talking in general terms about what you feel users are using, it's better to be scientific and find out!
    http://websnapshot.mycomputer.com/browsers.html is one site that tracks what people are actually using, and at the moment it appears that only a tiny fraction of users have non-JS compatible browsers.

    For this particular application JS is probably the most appropriate, though if the server supports it, a CGI script could be used to accomplish the same thing for those users that don't have JS.

    Who *are* these 0.7% using IE2? Masochists?

    On a more unscientific note, the idea that any significant number of users turn off JS in their browsers seems to me to be unlikely. This may be the case for a few techies, but I would imagine most users would be unaware what JS is, let alone that it is something that could be turned off.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    11
    Rep Power
    0
    These are good points. It's not my intention to keep new technology out of the picture, just to try to ensure some stability out there.

    Dunno - I guess working for the phone company squelches any desires one might have to use 'cutting edge' (read: less than 10-year-old ) technology.

    I'll quit wailing now...

    -Joe
  20. #11
  21. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    errrrrr - your gonna love this, after all that - I forgot to include the call to the script in the code I posted!! - yes I have punished myself severely.

    I forgot to add - onchange="addit()" to the 'how many cakes' input.

    Off to hide in the corner....

    Simon.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    Hi,

    Check out: http://cgi.resourceindex.com/Program...hopping_Carts/ and see what you think. I am sure you will find something useful there.

    Kelly
  24. #13
  25. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    5
    Rep Power
    0
    Can you give us the references?

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Dr_E_lectric:
    This may not be the answer you are loking for because it is not a php script. There are some free shopping carts on the net that will serv your purpose. Try one or two they may work for you. In any event you will get an idea of what you realy need before you start trying to write any code. Plus you are taking orders while you are wrighting and testing. [/quote]

  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Randolph, NJ
    Posts
    36
    Rep Power
    15
    http://www.hotscripts.com/PHP/Script...hopping_Carts/

    (for PHP shopping scripts)

    or
    http://www.hotscripts.com/Perl/Scrip...hopping_Carts/

    (for Perl shopping scripts)

    Hope some of those help.

IMN logo majestic logo threadwatch logo seochat tools logo