Hoi,
Ik gebruik dit script.
Nu wil ik niet met € 0.00 beginnen maar met € 2.00 zodat er altijd de verzendkosten worden berekend.
Iemand een idee?
Ik gebruik dit script.
Nu wil ik niet met € 0.00 beginnen maar met € 2.00 zodat er altijd de verzendkosten worden berekend.
Code:
<!-- hide javascript from non-JavaScript browsers.
// This function calculates the total for items in the form which are selected
var PriceAry=[];
PriceAry[0]=['Machtiging : € 0,00',0.00];
PriceAry[1]=['Betaling achteraf : € 2,50',2.50];
PriceAry[2]=['36 Labels : € 10,00',10.00];
PriceAry[3]=['72 Labels : € 20,00',20.00];
PriceAry[4]=['144 Labels : € 30,00',30.00];
PriceAry[5]=['Geen taggits : € 0,00',0.00];
PriceAry[6]=['100 Taggits : € 6,00',6.00];
PriceAry[7]=['200 Taggits : € 12,00',12.00];
PriceAry[8]=['Verzendkosten : € 2,00',2.00];
if (!frm.fields) frm.fields='';
function CalculateTotal(inputItem) {
var frm=inputItem.form;
if (!frm.fields) frm.fields='';
if (!frm.fields.match(inputItem.name)) frm.fields+=inputItem.name+',' // add the inputItem name to frm.fields
var fieldary=frm.fields.split(','); // convert frm.fields to an array
var cal=0;
for (var zxc0=0;zxc0<fieldary.length-1;zxc0++){ // loop through the field names
var input=document.getElementsByName(fieldary[zxc0]); // an array of fields with the mame
for (var zxc0a=0;zxc0a<input.length;zxc0a++){ // loop through the input array to detect checked fields
if (input[zxc0a].checked){
for (var zxc0b=0;zxc0b<PriceAry.length;zxc0b++){ // loop through PriceAry to match input value with field 0 of each field
if (input[zxc0a].value==PriceAry[zxc0b][0]){
cal+=PriceAry[zxc0b][1];
}
}
}
}
}
frm.calculatedTotal.value=cal;
frm.total.value=formatCurrency(cal);
}
// format a value as currency.
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '€ ' + num + '.' + cents);
}
// This function initialzes all the form elements to default values
function InitForm() {
//Reset values on form
var frm=document.selectionForm;
frm.total.value='€ 0.00'; // set initial total
frm.calculatedTotal.value=0;
frm.previouslySelectedRadioButton.value=0;
//Set all checkboxes and radio buttons on form to unchecked:
for (i=0; i < frm.elements.length; i++) {
if (frm.elements[i].type == 'checkbox' || frm.elements[i].type == 'radio') {
frm.elements[i].checked =(frm.elements[i].value!='None')? false:true;
}
}
}
// end commenting javascript -->
</SCRIPT>
Iemand een idee?