Dynamisk bestillingsformular
Hej,jeg skal lave en bestillingsformular til en kunde. Jeg har fundet følgende template på nettet, som egentlig gør det rigtige:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DeresFest Bestillingsliste</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("jquery", "1.2.6");
</script>
<script type="text/javascript" src="js/order.js"></script>
</head>
<body>
<div id="hook-just-in-case" style="background: #2f2626 !important; text-align: center !important; color: white !important; font: 14px Georgia, Serif !important; position: relative; width: 100% !important; z-index: 10000 !important;">
</div>
<table id="order-table">
<tr>
<th>Varens navn</th>
<th>Antal</th>
<th>X</th>
<th>Pris inkl. moms</th>
<th>=</th>
<th style="text-align: right;">Totalt</th>
</tr>
<tr class="odd">
<td><div id="produktgruppe">Porcelæn</div></td>
</tr>
<tr class="even">
<td class="product-title">Flade tallerkner</td>
<td class="num-pallets"><input type="text" class="num-pallets-input" id="sparkle-num-pallets"></input></td>
<td class="times">X</td>
<td class="price-per-pallet">$<span>1.25</span></td>
<td class="equals">=</td>
<td class="row-total"><input type="text" class="row-total-input" id="sparkle-row-total" disabled="disabled"></input></td>
</tr>
<tr class="odd">
<td class="product-title">Dybe tallerkner</td></td>
<td class="num-pallets"><input type="text" class="num-pallets-input" id="turface-mvp-num-pallets"></input></td>
<td class="times">X</td>
<td class="price-per-pallet">$<span>1.25</span></td>
<td class="equals">=</td>
<td class="row-total"><input type="text" class="row-total-input" id="turface-mvp-row-total" disabled="disabled"></input></td>
</tr>
<tr class="even">
<td class="product-title">Frokost tallerkner</td>
<td class="num-pallets"><input type="text" class="num-pallets-input" id="turface-pro-league-num-pallets" ></input></td>
<td class="times">X</td>
<td class="price-per-pallet">$<span>1.25</span></td>
<td class="equals">=</td>
<td class="row-total"><input type="text" class="row-total-input" id="turface-pro-league-row-total" disabled="disabled"></input></td>
</tr>
<tr class="odd">
<td class="product-title">Kop og kande</td>
<td class="num-pallets"><input type="text" class="num-pallets-input" id="turface-pro-league-red-num-pallets"></input></td>
<td class="times">X</td>
<td class="price-per-pallet">$<span>1.25</span></td>
<td class="equals">=</td>
<td class="row-total"><input type="text" class="row-total-input" id="turface-pro-league-red-row-total" disabled="disabled"></input></td>
</tr>
<tr class="even">
<td class="product-title">Kage tallerkner</td>
<td class="num-pallets"><input type="text" class="num-pallets-input" id="turface-quick-dry-num-pallets" ></input></td>
<td class="times">X</td>
<td class="price-per-pallet">$<span>1,25</span></td>
<td class="equals">=</td>
<td class="row-total"><input type="text" class="row-total-input" id="turface-quick-dry-row-total" disabled="disabled"></input></td>
</tr>
<tr class="odd">
<td class="product-title">Buillonkop</td>
<td class="num-pallets"><input type="text" class="num-pallets-input" id="turface-mound-clay-red-num-pallets"></input></td>
<td class="times">X</td>
<td class="price-per-pallet">$<span>1.25</span></td>
<td class="equals">=</td>
<td class="row-total"><input type="text" class="row-total-input" id="turface-mound-clay-red-row-total" disabled="disabled"></input></td>
</tr>
<tr>
<td colspan="6" style="text-align: right;">
Product SUBTOTAL: <input type="text" class="total-box" id="product-subtotal" disabled="disabled"></input>
</td>
</tr>
</table>
<table id="shipping-table">
<tr>
<th>Total Qty.</th>
<th>X</th>
<th>Shipping Rate</th>
<th>=</th>
<th style="text-align: right;">Shipping Total</th>
</tr>
<tr>
<td id="total-pallets"><input id="total-pallets-input" type="text" disabled="disabled"></input></td>
<td>X</td>
<td id="shipping-rate">10.00</td>
<td>=</td>
<td style="text-align: right;"><input type="text" class="total-box" id="shipping-subtotal" disabled="disabled"></input></td>
</tr>
</table>
<div class="clear"></div>
<div style="text-align: right;">
<span>Order total: </span>
<input type="text" class="total-box" id="order-total" disabled="disabled"></input>
<br />
<form action="#" method="post"></form>
<input type="submit" value="Submit Order" class="submit" />
</form>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-68528-29");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
Med tilhørende js.fil:
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
};
function calcProdSubTotal() {
var prodSubTotal = 0;
$(".row-total-input").each(function(){
var valString = $(this).val() || 0;
prodSubTotal += parseInt(valString);
});
$("#product-subtotal").val(prodSubTotal);
};
function calcTotalPallets() {
var totalPallets = 0;
$(".num-pallets-input").each(function() {
var thisValue = $(this).val();
if ( (IsNumeric(thisValue)) && (thisValue != '') ) {
totalPallets += parseInt(thisValue);
};
});
$("#total-pallets-input").val(totalPallets);
};
function calcShippingTotal() {
var totalPallets = $("#total-pallets-input").val() || 0;
var shippingRate = $("#shipping-rate").text() || 0;
var shippingTotal = totalPallets * shippingRate;
$("#shipping-subtotal").val(shippingTotal);
};
function calcOrderTotal() {
var orderTotal = 0;
var productSubtotal = $("#product-subtotal").val() || 0;
var shippingSubtotal = $("#shipping-subtotal").val() || 0;
var orderTotal = parseInt(productSubtotal) + parseInt(shippingSubtotal);
var orderTotalNice = "$" + orderTotal;
$("#order-total").val(orderTotalNice);
};
$(function(){
$('.num-pallets-input').blur(function(){
var $this = $(this);
var numPallets = $this.val();
var multiplier = $this
.parent().parent()
.find("td.price-per-pallet span")
.text();
if ( (IsNumeric(numPallets)) && (numPallets != '') ) {
var rowTotal = numPallets * multiplier;
$this
.css("background-color", "white")
.parent().parent()
.find("td.row-total input")
.val(rowTotal);
} else {
$this.css("background-color", "#ffdcdc");
};
calcProdSubTotal();
calcTotalPallets();
calcShippingTotal();
calcOrderTotal();
});
});
Mit problem er at jeg meget gerne vil fjerne $ tegnet og erstate det med kr. Samtidid er subtotal og shipping ikke interresant, men hvis jeg erstarter $ med kr og fjerne både subtotal og shipping fungerer formelen ikke?
Håber der er en der kan hjælpe måske enda komme med en færdig kode
mvh Thomas