Hi,
On [URL=http://www.coffeehit.com.au]http://www.coffeehit.com.au
I have a quick buy section that not only adds the items for a total, it also sends this info to a shop cart. (shop cart link disabled, having trouble parsing multi items in one pass – that’s another story).
Anyway am parsing single items to cart ok. Can see it working in [URL=http://www.coffeehit.com.au/ch_products_blends_daily.html]Coffee Blends
Problem is that now the cart is being populated the [B]item total calc
I’ve tried just about everything I know to get it going…
If someone could take a quick look I’d sure appreciate it, thanks.
BTW here is acopy of the javascript code:
[code]
<script type=”text/javascript”>
<!–
//+——————————–+
//| Please DO NOT remove |
//+——————————–+
//| |
//| Script Written by BlankMotion |
| [url]www.blankmotion.com.au[/url] |
//| |
//+——————————–+
//| Please DO NOT remove |
//+——————————–+
function sum(i)
{
sum1= eval(‘document.coffeeorder.grind’+i+’.value’)
sum2= eval(‘document.coffeeorder.weight’+i+’.value’)
cost= eval(‘document.coffeeorder.cost’+i+’.value’)
sum1 = parseInt(sum1)
sum2 = parseInt(sum2)
cost = parseInt(cost)
total=sum2*(cost+sum1)
var subtotal = eval(‘document.coffeeorder.subtotal’ + i);
subtotal.value = roundNumber(total)
}
function roundNumber(number) {
var rlength = 2; // The number of decimal places to round to
var newnumber = Math.round(number*Math.pow(10,rlength))/Math.pow(10,rlength);
return pad_with_zeros(newnumber, 2)
}
function pad_with_zeros(rounded_value, decimal_places) {
// Convert the number to a string
var value_string = rounded_value.toString()
// Locate the decimal point
var decimal_location = value_string.indexOf(“.”)
// Is there a decimal point?
if (decimal_location == -1) {
// If no, then all decimal places will be padded with 0s
decimal_part_length = 0
// If decimal_places is greater than zero, tack on a decimal point
value_string += decimal_places > 0 ? “.” : “”
}
else {
// If yes, then only the extra decimal places will be padded with 0s
decimal_part_length = value_string.length – decimal_location – 1
}
// Calculate the number of decimal places that need to be padded with 0s
var pad_total = decimal_places – decimal_part_length
if (pad_total > 0) {
// Pad the string with 0s
for (var counter = 1; counter <= pad_total; counter++)
value_string += “0”
}
return value_string
}
//–>
</script>
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>- Coffee Hit - Your coffee place in cyberspace</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/coffeehit_template.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
function sum(i)
{
var totalitems = 6;
sum1= eval('document.coffeeorder.grind'+i+'.value')
sum2= eval('document.coffeeorder.weight'+i+'.value')
cost= eval('document.coffeeorder.cost'+i+'.value')
sum1 = parseInt(sum1)
sum2 = parseInt(sum2)
cost = parseInt(cost)
total=sum2*(cost+sum1)
var subtotal = eval('document.coffeeorder.subtotal' + i);
subtotal.value = "$"+roundNumber(total)
var total = 0;
for(var i=1; i<=totalitems; i++){
var subadd = eval('document.coffeeorder.subtotal' + i);
subadd = subadd.value.replace("$", '') ;
totaladd = parseInt(subadd)
total += totaladd;
}
document.coffeeorder.total.value = "$"+roundNumber(total)+"*";
}
function roundNumber(number) {
var rlength = 2; // The number of decimal places to round to
var newnumber = Math.round(number*Math.pow(10,rlength))/Math.pow(10,rlength);
return pad_with_zeros(newnumber, 2)
}
function pad_with_zeros(rounded_value, decimal_places) {
<i> </i>// Convert the number to a string
<i> </i>var value_string = rounded_value.toString()
<i> </i>// Locate the decimal point
<i> </i>var decimal_location = value_string.indexOf(".")
<i> </i>// Is there a decimal point?
<i> </i>if (decimal_location == -1) {
<i> </i> // If no, then all decimal places will be padded with 0s
<i> </i> decimal_part_length = 0
<i> </i> // If decimal_places is greater than zero, tack on a decimal point
<i> </i> value_string += decimal_places > 0 ? "." : ""
<i> </i>}
<i> </i>else {
<i> </i> // If yes, then only the extra decimal places will be padded with 0s
<i> </i> decimal_part_length = value_string.length - decimal_location - 1
<i> </i>}
<i> </i>// Calculate the number of decimal places that need to be padded with 0s
<i> </i>var pad_total = decimal_places - decimal_part_length
<i> </i>if (pad_total > 0) {
<i> </i> // Pad the string with 0s
<i> </i> for (var counter = 1; counter <= pad_total; counter++)
<i> </i> value_string += "0"
<i> </i> }
<i> </i>return value_string
}
....
[i]Originally posted by oz_guy61 [/i]
[B]And your point is?
Anyway thanks for looking at the script, I would however prefer to hear from someone who can give a definative answer to the problem... [/B][/QUOTE]
[i]Originally posted by oz_guy61 [/i]
[B]Hi,
On[URL=http://www.coffeehit.com.au]http://www.coffeehit.com.au[/URL]
I have a quick buy section that not only adds the items for a total, it also sends this info to a shop cart. (shop cart link disabled, having trouble parsing multi items in one pass - that's another story).
Anyway am parsing single items to cart ok. Can see it working in[URL=http://www.coffeehit.com.au/ch_products_blends_daily.html]Coffee Blends[/URL]
Problem is that now the cart is being populated the [B]item total calc[/B] is not functioning ?
I've tried just about everything I know to get it going...
If someone could take a quick look I'd sure appreciate it, thanks.
BTW here is acopy of the javascript code:
[/B][/QUOTE]
<i>
</i><script type="text/javascript">
<!--
//+--------------------------------+
//| Please DO NOT remove |
//+--------------------------------+
//| |
//| Script Written by BlankMotion |
| <a href="www.blankmotion.com.au">www.blankmotion.com.au</a> |
//| |
//+--------------------------------+
//| Please DO NOT remove |
//+--------------------------------+
function sum(i)
{
sum1= eval('document.coffeeorder.grind'+i+'.value')
sum2= eval('document.coffeeorder.weight'+i+'.value')
cost= eval('document.coffeeorder.cost'+i+'.value')
sum1 = parseInt(sum1)
sum2 = parseInt(sum2)
cost = parseInt(cost)
total=sum2*(cost+sum1)
var subtotal = eval('document.coffeeorder.subtotal' + i);
subtotal.value = roundNumber(total)
}
function roundNumber(number) {
var rlength = 2; // The number of decimal places to round to
var newnumber = Math.round(number*Math.pow(10,rlength))/Math.pow(10,rlength);
return pad_with_zeros(newnumber, 2)
}
function pad_with_zeros(rounded_value, decimal_places) {
<i> </i>// Convert the number to a string
<i> </i>var value_string = rounded_value.toString()
<i> </i>// Locate the decimal point
<i> </i>var decimal_location = value_string.indexOf(".")
<i> </i>// Is there a decimal point?
<i> </i>if (decimal_location == -1) {
<i> </i> // If no, then all decimal places will be padded with 0s
<i> </i> decimal_part_length = 0
<i> </i> // If decimal_places is greater than zero, tack on a decimal point
<i> </i> value_string += decimal_places > 0 ? "." : ""
<i> </i>}
<i> </i>else {
<i> </i> // If yes, then only the extra decimal places will be padded with 0s
<i> </i> decimal_part_length = value_string.length - decimal_location - 1
<i> </i>}
<i> </i>// Calculate the number of decimal places that need to be padded with 0s
<i> </i>var pad_total = decimal_places - decimal_part_length
<i> </i>if (pad_total > 0) {
<i> </i> // Pad the string with 0s
<i> </i> for (var counter = 1; counter <= pad_total; counter++)
<i> </i> value_string += "0"
<i> </i> }
<i> </i>return value_string
}
//-->
</script>
[i]Originally posted by Willy Duitt [/i]
[B]And the point would be you come to a developers site asking question regarding a script another developer has written and took the bother to add his credits too, and whom may very well be a member here, and you ask for help modifying the script after you exhibit the disrespect of removing the authors credits on your site...
The fact that you had sense enough to return the credits here while they were removed on your sites speaks worse towards your intentions and reflects poorly upon your character...
Good luck finding someone to aide and abet you in your quest to plagiarize someones work... I certainly am not going to help you other than notify the author so he can have your site taken down...
Have many nice days;
.....Willy [/B][/QUOTE]
<i>
</i> <form name="coffeeorder" action="http://www.coffeehit.com.au/shopcart/index.php?main_page=product_info&cPath=2&products_id=1&number_of_uploads=0&action=add_product" method="post" enctype="multipart/form-data">
<tr>
<td width="68" valign="middle"><select name="weight1" class="xorderdrop" id="weight1" onchange="sum(1)">
<option selected="selected" value='0'>Select Kg</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
</select></td>
<td width="79" valign="middle"><select name="grind1" class="xorderdrop2" id="grind1" onChange="sum(1)">
<option value='0'>Grind Type</option><option value="1">Expresso +$1Kg</option><option value="2">Filter +$1Kg</option><option value="3">Perculator +$1Kg</option><option value="4">Plunger +$1Kg</option><option value="5">Whole Bean</option>
</select></td>
<td width="110" align="center" valign="top"><input name="subtotal1" type="text" class="xorderPrice" id="subtotal1" value="$0.00" readonly="">
<input type="hidden" name="cost1" value="12"></td>
<input type="hidden" name="products_id" value="1" />
<td width="10" align="center" valign="top"></td>
<td width="105" align="center" valign="top"><input name="image" type="image" src="CH_images/blends/xorder_check_outbt.gif"></td>
</tr></form>
[i]Originally posted by oz_guy61 [/i]
[B]Hmmm how do you know I'm not from blankmotion.com.au (check my IP I'm from OZ too) In fact I'm part of the development team for the Coffee Hit site.
Blank Motion did the front end design, including the JavaScript. However I'm having trouble getting the damn script to function. It is the weekend here & can't contact BlankMotion, hence thought I'd post it here and see if someone can get it to work...
Is there a law against that?
In regards to your assumption that I stole the script..Wrong again...
The reason the “please do not remove” was added to the script here should be perfectly clear.
In future before you burn a witch make sure that it is a witch...
You owe me a BIG apology Willy!!! [/B][/QUOTE]
http://blankmotion.com.au/html/contact.php
HTTP Request Header
Connect to 216.71.218.118 on port 80 ... ok
GET / HTTP/1.1[CRLF]
Host: blankmotion.com.au[CRLF]
Connection: close[CRLF]
Accept-Encoding: gzip[CRLF]
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*[CRLF]
Accept-Language: en-us[CRLF]
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) Web-Sniffer/1.0.20[CRLF]
Referer:http://web-sniffer.net/ [CRLF]
[CRLF]
HTTP Response Header
Name Value Delim
HTTP Status Code: HTTP/1.1 200 OK
Date: Sun, 30 Jan 2005 02:48:54 GMT CRLF
Server: Apache/1.3.26 (Unix) FrontPage/5.0.2.2510 CRLF
Last-Modified: Mon, 16 Aug 2004 04:47:50 GMT CRLF
ETag: "cc00a-127a-41203c76" CRLF
Accept-Ranges: bytes CRLF
Content-Length: 4730 CRLF
Connection: close CRLF
Content-Type: text/html CRLF
Content (4.62 Ki?
http://www.coffeehit.com.au
HTTP Request Header
Connect to 202.147.97.195 on port 80 ... ok
GET / HTTP/1.1[CRLF]
Host:www.coffeehit.com.au [CRLF]
Connection: close[CRLF]
Accept-Encoding: gzip[CRLF]
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*[CRLF]
Accept-Language: en-us[CRLF]
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) Web-Sniffer/1.0.20[CRLF]
Referer:http://web-sniffer.net/ [CRLF]
[CRLF]
HTTP Response Header
Name Value Delim
HTTP Status Code: HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0 CRLF
X-Powered-By: ASP.NET CRLF
Connection: close CRLF
Content-Location:http://www.coffeehit.com.au/home.html CRLF
Date: Sun, 30 Jan 2005 02:55:28 GMT CRLF
Content-Type: text/html CRLF
Accept-Ranges: bytes CRLF
Last-Modified: Thu, 27 Jan 2005 04:57:50 GMT CRLF
ETag: "f8537cc02c4c51:ddf" CRLF
Content-Length: 30312 CRLF
Content (29.60 Ki?
[/quote]
<i>
</i><a href="http://www.mcfedries.com/JavaScript/Rounder.asp">http://www.mcfedries.com/JavaScript/Rounder.asp</a>
<script language="JavaScript" type="text/javascript">
<!--
/* This script is Copyright (c) Paul McFedries and
Logophilia Limited (<a href="http://www.mcfedries.com/">http://www.mcfedries.com/</a>).
Permission is granted to use this script as long as
this Copyright notice remains in place.*/
function CalculateTotal(frm) {
var order_total = 0
// Run through all the form fields
for (var i=0; i < frm.elements.length; ++i) {
// Get the current field
form_field = frm.elements[i]
// Get the field's name
form_name = form_field.name
// Is it a "product" field?
if (form_name.substring(0,4) == "PROD") {
// If so, extract the price from the name
item_price = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))
// Get the quantity
item_quantity = parseInt(form_field.value)
// Update the order total
if (item_quantity >= 0) {
order_total += item_quantity * item_price
}
}
}
// Display the total rounded to two decimal places
frm.TOTAL.value = round_decimals(order_total, 2)
}
function round_decimals(original_number, decimals) {
var result1 = original_number * Math.pow(10, decimals)
var result2 = Math.round(result1)
var result3 = result2 / Math.pow(10, decimals)
return pad_with_zeros(result3, decimals)
}
function pad_with_zeros(rounded_value, decimal_places) {
// Convert the number to a string
var value_string = rounded_value.toString()
// Locate the decimal point
var decimal_location = value_string.indexOf(".")
// Is there a decimal point?
if (decimal_location == -1) {
// If no, then all decimal places will be padded with 0s
decimal_part_length = 0
// If decimal_places is greater than zero, tack on a decimal point
value_string += decimal_places > 0 ? "." : ""
}
else {
// If yes, then only the extra decimal places will be padded with 0s
decimal_part_length = value_string.length - decimal_location - 1
}
// Calculate the number of decimal places that need to be padded with 0s
var pad_total = decimal_places - decimal_part_length
if (pad_total > 0) {
// Pad the string with 0s
for (var counter = 1; counter <= pad_total; counter++)
value_string += "0"
}
return value_string
}
//-->
</script>
[i]Originally posted by Willy Duitt [/i]
[B]If all this is true... Why did you not explain your side long ago when I first asked instead of replying with a "[b]Whats it to you[/b]" whci required further explanation of why I asked...
Firstly if you intend to quote me at least have the manners to keep the context correct. (Yes Willy I'm really Pissed). EG - "[b]Whats it to you[/b]" where did I say that...
Perhaps I will recieve a reply from my missive to Blank Motion and if it turns out that what you are now representing is true, we will consider an apology... But, if you were upfront from the start, all this could have possibly been avoided...
.....Willy [/B][/QUOTE]
[i]Originally posted by oz_guy61 [/i]
[B]What is it with people like you???
I don't recall in the T&C's the section that states, [b]If Willy Duitt confronts you in regards to a post I swear that I will answer him & tell him everything he asks[/b].
As a piece of advice & for future reference...
A smart person would have emailed Blank Motion first asked the question. If your assumptions of theft were correct, then posted the truth here. Otherwise stfu & post nothing!
PS If your going to quote me please do so in my own words...That's what the " " mean!!! [/B][/QUOTE]
/* This script is Copyright (c) Paul McFedries and
Logophilia Limited (http://www.mcfedries.com/ ).
Permission is granted to use this script as long as
this Copyright notice remains in place.*/
[/quote]
[i]Originally posted by oz_guy61 [/i]
[B]In reference to your question...
The reason I posted the "please do not remove" on the code is, it is not my code & out of courtisy I though it best to add a simply acknowledgement to Blank Motion for it, seeing this could be construded as public domain.
That's it in a nut shell.
Ok it's not in proper syntax...sorry. [/B][/QUOTE]
1: <script type="text/javascript">
2: <!--
3: //+--------------------------------+
4: //| Please DO NOT remove |
5: //+--------------------------------+
6: //| |
7: //| Script Written by BlankMotion |
8: |www.blankmotion.com.au |
9: //| |
10: //+--------------------------------+
11: //| Please DO NOT remove |
12: //+--------------------------------+
13:
14:
[/quote]
0.1.9 — BETA 5.15