I have found a fine working script that will calculate the total prize of the items tagged in the orderform, but need to add the feature of multiplying the amount of each order. Can anybody help out here?
Here's the orderform:
<form name=orderform action="confirm-order.html">
<table width="700" border="1" align="center" bordercolor="#CCCCCC">
<tr>
<td width="65">
<input type=checkbox name=0001 value=http://www.webdeveloper.com/forum/archive/index.php/"0001-Vare_er_blablabla*400,00$">
</td>
<td width="69">0001</td>
<td width="382">Vare nr. 0001 er blablabla</td>
<td width="156">400,00 kr.</td>
</tr>
<tr>
<td>
<input type=checkbox name=0002 value="0002-Vare_er_blablabla*750,00$"></td>
<td>0002</td>
<td>Vare nr. 0002 er blablabla</td>
<td>750,00 kr.</td>
</tr>
<tr>
<td>
<input type=checkbox name=0003 value="0003-Vare_er_blablabla*650,00$"></td>
<td>0003</td>
<td>Vare nr. 0003 er blablabla</td>
<td>650,00 kr.</td>
</tr>
<tr>
<td width="65">
<input type=checkbox name=0004 value="0004-Vare_er_blablabla*350,00$">
</td>
<td width="69">0004</td>
<td width="382">Vare nr. 0004 er blablabla</td>
<td width="156">350,00 kr.</td>
</tr>
<tr>
<td colspan=4 align=center>
<input type=submit value="Bestil vare(r)">
</td>
</tr>
</table>
<br></form>
And here's the code for the <head> of the confirm-order.html page:
<SCRIPT LANGUAGE="JavaScript">
<!--
<!-- Begin
function decodeString() {
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData, grandTotal;
string = "" + unescape(location.search);
string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c < string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;
orderData = "<table border=1 width=700 bordercolor=#CCCCCC>";
orderData += "<tr><td><b>Varenr.<b/></td><td><b>Beskrivelse</b></td><td><b>Pris i Dkr.</b></td></tr>";
grandTotal = 0;
for (var i = 0; i < dataCount; i++)
{
valNum = string.substring(0,string.indexOf("="));
string = string.substring(string.indexOf("=")+1,string.length);
if (i == dataCount-1) valData = string;
else valData = string.substring(0,string.indexOf("&"));
ampd = valData.indexOf("&");
pipe = valData.indexOf("-");
star = valData.indexOf("*");
line = valData.indexOf("$");
varenummer = string.substring(0,pipe);
varedsc = string.substring(pipe+1,star);
varecst = string.substring(star+1,line);
string = string.substring(ampd+1,string.length);
orderData += "<tr>";
orderData += "<input type=hidden name=vare" + (i+1) + "num value='http://www.webdeveloper.com/forum/archive/index.php/" + varenummer + "'>";
orderData += "<input type=hidden name=vare" + (i+1) + "dsc value='http://www.webdeveloper.com/forum/archive/index.php/" + varedsc + "'>";
orderData += "<input type=hidden name=vare" + (i+1) + "cst value='http://www.webdeveloper.com/forum/archive/index.php/$" + varecst + "'>";
orderData += "<td>" + varenummer + "</td>";
orderData += "<td>" + varedsc + "</td>";
orderData += "<td>" + varecst + "</td>";
orderData += "</tr>";
grandTotal += parseInt(varecst);
}
orderData += "<tr>";
orderData += "<td colspan=2 align=right><b>Total: </b></td><td>" + grandTotal + ".00</td>";
orderData += "</tr>";
orderData += "<input type=hidden name=grandtotal value='http://www.webdeveloper.com/forum/archive/index.php/Dkr. " + grandTotal + ".00'>";
orderData += "</table>";
document.write(orderData);
}
</script>
Here's the orderform:
<form name=orderform action="confirm-order.html">
<table width="700" border="1" align="center" bordercolor="#CCCCCC">
<tr>
<td width="65">
<input type=checkbox name=0001 value=http://www.webdeveloper.com/forum/archive/index.php/"0001-Vare_er_blablabla*400,00$">
</td>
<td width="69">0001</td>
<td width="382">Vare nr. 0001 er blablabla</td>
<td width="156">400,00 kr.</td>
</tr>
<tr>
<td>
<input type=checkbox name=0002 value="0002-Vare_er_blablabla*750,00$"></td>
<td>0002</td>
<td>Vare nr. 0002 er blablabla</td>
<td>750,00 kr.</td>
</tr>
<tr>
<td>
<input type=checkbox name=0003 value="0003-Vare_er_blablabla*650,00$"></td>
<td>0003</td>
<td>Vare nr. 0003 er blablabla</td>
<td>650,00 kr.</td>
</tr>
<tr>
<td width="65">
<input type=checkbox name=0004 value="0004-Vare_er_blablabla*350,00$">
</td>
<td width="69">0004</td>
<td width="382">Vare nr. 0004 er blablabla</td>
<td width="156">350,00 kr.</td>
</tr>
<tr>
<td colspan=4 align=center>
<input type=submit value="Bestil vare(r)">
</td>
</tr>
</table>
<br></form>
And here's the code for the <head> of the confirm-order.html page:
<SCRIPT LANGUAGE="JavaScript">
<!--
<!-- Begin
function decodeString() {
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData, grandTotal;
string = "" + unescape(location.search);
string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c < string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;
orderData = "<table border=1 width=700 bordercolor=#CCCCCC>";
orderData += "<tr><td><b>Varenr.<b/></td><td><b>Beskrivelse</b></td><td><b>Pris i Dkr.</b></td></tr>";
grandTotal = 0;
for (var i = 0; i < dataCount; i++)
{
valNum = string.substring(0,string.indexOf("="));
string = string.substring(string.indexOf("=")+1,string.length);
if (i == dataCount-1) valData = string;
else valData = string.substring(0,string.indexOf("&"));
ampd = valData.indexOf("&");
pipe = valData.indexOf("-");
star = valData.indexOf("*");
line = valData.indexOf("$");
varenummer = string.substring(0,pipe);
varedsc = string.substring(pipe+1,star);
varecst = string.substring(star+1,line);
string = string.substring(ampd+1,string.length);
orderData += "<tr>";
orderData += "<input type=hidden name=vare" + (i+1) + "num value='http://www.webdeveloper.com/forum/archive/index.php/" + varenummer + "'>";
orderData += "<input type=hidden name=vare" + (i+1) + "dsc value='http://www.webdeveloper.com/forum/archive/index.php/" + varedsc + "'>";
orderData += "<input type=hidden name=vare" + (i+1) + "cst value='http://www.webdeveloper.com/forum/archive/index.php/$" + varecst + "'>";
orderData += "<td>" + varenummer + "</td>";
orderData += "<td>" + varedsc + "</td>";
orderData += "<td>" + varecst + "</td>";
orderData += "</tr>";
grandTotal += parseInt(varecst);
}
orderData += "<tr>";
orderData += "<td colspan=2 align=right><b>Total: </b></td><td>" + grandTotal + ".00</td>";
orderData += "</tr>";
orderData += "<input type=hidden name=grandtotal value='http://www.webdeveloper.com/forum/archive/index.php/Dkr. " + grandTotal + ".00'>";
orderData += "</table>";
document.write(orderData);
}
</script>