Hoping someone an assist me urgently. I would truly appreciate and help.
I have a form and prices are based on 'price break'.
1.The price break fields work fine, but I cannot for the life of me add more
than one to a page.
2. Also need to add the two results to a 'total' field. (See code attached).
Many thanks in advance.
Sample code ...
<HEAD>
</HEAD>
<BODY onLoad="findPri ce();">
<SCRIPT LANGUAGE="JavaS cript">
<!-- Begin
var max_hsunits1 = 1000; // quantities in excess of max_hsunits1 all have
the same unit price
var currency = "$"; // currency sign used in 'formatMessage( )'
// Edit this function to reflect discount prices!
function getDiscountPric e(hsunits1) {
// Note: Work way down from max to min amounts!
if (hsunits1 >= max_hsunits1) return 18;
if (hsunits1 >= 750) return 20;
if (hsunits1 >= 500) return 25;
if (hsunits1 >= 250) return 28;
if (hsunits1 >= 150) return 30;
if (hsunits1 >= 75) return 31;
if (hsunits1 >= 50) return 40;
if (hsunits1 >= 25) return 45;
if (hsunits1 >= 10) return 47;
if (hsunits1 >= 5) return 50;
if (hsunits1 >= 1) return 55;
if (hsunits1 <= 0) return 0;
}
function getNumberOfUnit s() {
var hsunits1 = document.Hypers nap.hsunits1.va lue;
return (hsunits1 == "") ? 0 : hsunits1;
}
function showResult(resu lt) {
// adjust the following line if result must popup somewhere else
document.Hypers nap.hsresult1.v alue = result;
}
function formatMessage(h sunits1, unit_price) {
return hsunits1 + " * " + currency + formatPrice(uni t_price) + " = " +
currency + formatPrice(hsu nits1 * unit_price);
}
// AltUnits (alternate hsunits1): add extra hsunits1 to reach minimum for
next discount price
function getAltUnits(hsu nits1) {
var discount_price = getDiscountPric e(hsunits1);
if (hsunits1 < max_hsunits1) do { hsunits1++ } while (discount_price ==
getDiscountPric e(hsunits1));
return hsunits1;
}
function findPrice() {
var hsunits1 = getNumberOfUnit s();
var unit_price = getDiscountPric e(hsunits1);
var alt_hsunits1 = getAltUnits(hsu nits1);
var alt_unit_price = getDiscountPric e(alt_hsunits1) ;
var result;
if ((hsunits1 * unit_price) < (alt_hsunits1 * alt_unit_price) )
result = formatMessage(h sunits1, unit_price);
else
result = formatMessage(a lt_hsunits1, alt_unit_price) ;
showResult(resu lt);
}
function formatPrice(val ue) {
var result= Math.floor(valu e) + ".";
var cents = 100 * (value-Math.floor(valu e)) + 0.5;
result += Math.floor(cent s / 10);
result += Math.floor(cent s % 10);
return result;
}
function filterNonNumeri c(field) {
var result = new String();
var numbers = "0123456789 ";
var chars = field.value.spl it(""); // create array
for (i = 0; i < chars.length; i++) {
if (numbers.indexO f(chars[i]) != -1) result += chars[i];
}
if (field.value != result) field.value = result;
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaS cript">
<!-- Begin
var max_hsunits2 = 1000; // quantities in excess of max_hsunits2 all have
the same unit price
var currency = "$"; // currency sign used in 'formatMessage2 ()'
// Edit this function to reflect your discount prices!
function getDiscountPric e2(hsunits2) {
// Note: It is important to work your way down from max to min amounts!
if (hsunits2 >= max_hsunits2) return 18;
if (hsunits2 >= 750) return 20;
if (hsunits2 >= 500) return 25;
if (hsunits2 >= 250) return 28;
if (hsunits2 >= 150) return 30;
if (hsunits2 >= 75) return 31;
if (hsunits2 >= 50) return 40;
if (hsunits2 >= 25) return 45;
if (hsunits2 >= 10) return 47;
if (hsunits2 >= 5) return 50;
if (hsunits2 >= 1) return 55;
if (hsunits2 <= 0) return 0;
}
function getNumberOfUnit s2() {
var hsunits2 = document.Hypers nap.hsunits2.va lue2;
return (hsunits2 == "") ? 0 : hsunits2;
}
function showResult2(res ult2) {
// adjust the following line if result2 must popup somewhere else
document.Hypers nap.hsresult22. value2 = result2;
}
function formatMessage2( hsunits2, unit_price2) {
return hsunits2 + " * " + currency + formatPrice2(un it_price2) + " = " +
currency + formatPrice2(hs units2 * unit_price2);
}
// AltUnits2 (alternate hsunits2): add extra hsunits2 to reach minimum for
next discount price
function getAltUnits2(hs units2) {
var discount_price2 = getDiscountPric e2(hsunits2);
if (hsunits2 < max_hsunits2) do { hsunits2++ } while (discount_price 2 ==
getDiscountPric e2(hsunits2));
return hsunits2;
}
function findPrice2() {
var hsunits2 = getNumberOfUnit s2();
var unit_price2 = getDiscountPric e2(hsunits2);
var alt_hsunits2 = getAltUnits2(hs units2);
var alt_unit_price2 = getDiscountPric e2(alt_hsunits2 );
var result2;
if ((hsunits2 * unit_price2) < (alt_hsunits2 * alt_unit_price2 ))
result2 = formatMessage2( hsunits2, unit_price2);
else
result2 = formatMessage2( alt_hsunits2, alt_unit_price2 );
showResult2(res ult2);
}
function formatPrice2(va lue2) {
var result2= Math.floor(valu e2) + ".";
var cents = 100 * (value-Math.floor(valu e2)) + 0.5;
result2 += Math.floor(cent s / 10);
result2 += Math.floor(cent s % 10);
return result2;
}
function filterNonNumeri c(field) {
var result2 = new String();
var numbers = "0123456789 ";
var chars = field.value.spl it(""); // create array
for (i = 0; i < chars.length; i++) {
if (numbers.indexO f(chars[i]) != -1) result2 += chars[i];
}
if (field.value2 != result2) field.value = result2;
}
// End -->
</script>
<form name="Hypersnap " method="post">
<p><font face="Arial" size="2"><b>Num ber of Users Required :</b></font>
<input type=text value="1" name="hsunits1" onkeydown="find Price()"
onKeyUp="filter NonNumeric(this ); findPrice()" onkeypress="fin dPrice()"
size="4" style="font-weight:bold; text-align:center;">
<input type=text onfocus="this.b lur()" name="hsresult1 " size="24"
style="border:0 ; font-weight:bold;">
<br><font face="Arial" size="2"><b>Num ber of Users Required :</b></font>
<input type=text value="1" name="hsunits2" onkeydown="find Price()"
onKeyUp="filter NonNumeric(this ); findPrice()" onkeypress="fin dPrice()"
size="4" style="font-weight:bold; text-align:center;">
<input type=text onfocus="this.b lur()" name="hsresult2 " size="24"
style="border:0 ; font-weight:bold;">
</form>
<form name="form1">
<p align="left"><f ont
color="black">< strong>Total Sales
&nb sp; &nb sp; &nb s
p; & nbsp; &nbs p; & nbsp; &nbs p; <input
type="text" name="hstotal" value="0.00" size="16"
onchange="Compu teForm()"
style="font-family:Arial; font-style:normal;
font-weight:bolder; font-size:11pt; color:white; background-color:black;"
language="JavaS cript"></strong></font></p>
</form>
</html>
I have a form and prices are based on 'price break'.
1.The price break fields work fine, but I cannot for the life of me add more
than one to a page.
2. Also need to add the two results to a 'total' field. (See code attached).
Many thanks in advance.
Sample code ...
<HEAD>
</HEAD>
<BODY onLoad="findPri ce();">
<SCRIPT LANGUAGE="JavaS cript">
<!-- Begin
var max_hsunits1 = 1000; // quantities in excess of max_hsunits1 all have
the same unit price
var currency = "$"; // currency sign used in 'formatMessage( )'
// Edit this function to reflect discount prices!
function getDiscountPric e(hsunits1) {
// Note: Work way down from max to min amounts!
if (hsunits1 >= max_hsunits1) return 18;
if (hsunits1 >= 750) return 20;
if (hsunits1 >= 500) return 25;
if (hsunits1 >= 250) return 28;
if (hsunits1 >= 150) return 30;
if (hsunits1 >= 75) return 31;
if (hsunits1 >= 50) return 40;
if (hsunits1 >= 25) return 45;
if (hsunits1 >= 10) return 47;
if (hsunits1 >= 5) return 50;
if (hsunits1 >= 1) return 55;
if (hsunits1 <= 0) return 0;
}
function getNumberOfUnit s() {
var hsunits1 = document.Hypers nap.hsunits1.va lue;
return (hsunits1 == "") ? 0 : hsunits1;
}
function showResult(resu lt) {
// adjust the following line if result must popup somewhere else
document.Hypers nap.hsresult1.v alue = result;
}
function formatMessage(h sunits1, unit_price) {
return hsunits1 + " * " + currency + formatPrice(uni t_price) + " = " +
currency + formatPrice(hsu nits1 * unit_price);
}
// AltUnits (alternate hsunits1): add extra hsunits1 to reach minimum for
next discount price
function getAltUnits(hsu nits1) {
var discount_price = getDiscountPric e(hsunits1);
if (hsunits1 < max_hsunits1) do { hsunits1++ } while (discount_price ==
getDiscountPric e(hsunits1));
return hsunits1;
}
function findPrice() {
var hsunits1 = getNumberOfUnit s();
var unit_price = getDiscountPric e(hsunits1);
var alt_hsunits1 = getAltUnits(hsu nits1);
var alt_unit_price = getDiscountPric e(alt_hsunits1) ;
var result;
if ((hsunits1 * unit_price) < (alt_hsunits1 * alt_unit_price) )
result = formatMessage(h sunits1, unit_price);
else
result = formatMessage(a lt_hsunits1, alt_unit_price) ;
showResult(resu lt);
}
function formatPrice(val ue) {
var result= Math.floor(valu e) + ".";
var cents = 100 * (value-Math.floor(valu e)) + 0.5;
result += Math.floor(cent s / 10);
result += Math.floor(cent s % 10);
return result;
}
function filterNonNumeri c(field) {
var result = new String();
var numbers = "0123456789 ";
var chars = field.value.spl it(""); // create array
for (i = 0; i < chars.length; i++) {
if (numbers.indexO f(chars[i]) != -1) result += chars[i];
}
if (field.value != result) field.value = result;
}
// End -->
</script>
<SCRIPT LANGUAGE="JavaS cript">
<!-- Begin
var max_hsunits2 = 1000; // quantities in excess of max_hsunits2 all have
the same unit price
var currency = "$"; // currency sign used in 'formatMessage2 ()'
// Edit this function to reflect your discount prices!
function getDiscountPric e2(hsunits2) {
// Note: It is important to work your way down from max to min amounts!
if (hsunits2 >= max_hsunits2) return 18;
if (hsunits2 >= 750) return 20;
if (hsunits2 >= 500) return 25;
if (hsunits2 >= 250) return 28;
if (hsunits2 >= 150) return 30;
if (hsunits2 >= 75) return 31;
if (hsunits2 >= 50) return 40;
if (hsunits2 >= 25) return 45;
if (hsunits2 >= 10) return 47;
if (hsunits2 >= 5) return 50;
if (hsunits2 >= 1) return 55;
if (hsunits2 <= 0) return 0;
}
function getNumberOfUnit s2() {
var hsunits2 = document.Hypers nap.hsunits2.va lue2;
return (hsunits2 == "") ? 0 : hsunits2;
}
function showResult2(res ult2) {
// adjust the following line if result2 must popup somewhere else
document.Hypers nap.hsresult22. value2 = result2;
}
function formatMessage2( hsunits2, unit_price2) {
return hsunits2 + " * " + currency + formatPrice2(un it_price2) + " = " +
currency + formatPrice2(hs units2 * unit_price2);
}
// AltUnits2 (alternate hsunits2): add extra hsunits2 to reach minimum for
next discount price
function getAltUnits2(hs units2) {
var discount_price2 = getDiscountPric e2(hsunits2);
if (hsunits2 < max_hsunits2) do { hsunits2++ } while (discount_price 2 ==
getDiscountPric e2(hsunits2));
return hsunits2;
}
function findPrice2() {
var hsunits2 = getNumberOfUnit s2();
var unit_price2 = getDiscountPric e2(hsunits2);
var alt_hsunits2 = getAltUnits2(hs units2);
var alt_unit_price2 = getDiscountPric e2(alt_hsunits2 );
var result2;
if ((hsunits2 * unit_price2) < (alt_hsunits2 * alt_unit_price2 ))
result2 = formatMessage2( hsunits2, unit_price2);
else
result2 = formatMessage2( alt_hsunits2, alt_unit_price2 );
showResult2(res ult2);
}
function formatPrice2(va lue2) {
var result2= Math.floor(valu e2) + ".";
var cents = 100 * (value-Math.floor(valu e2)) + 0.5;
result2 += Math.floor(cent s / 10);
result2 += Math.floor(cent s % 10);
return result2;
}
function filterNonNumeri c(field) {
var result2 = new String();
var numbers = "0123456789 ";
var chars = field.value.spl it(""); // create array
for (i = 0; i < chars.length; i++) {
if (numbers.indexO f(chars[i]) != -1) result2 += chars[i];
}
if (field.value2 != result2) field.value = result2;
}
// End -->
</script>
<form name="Hypersnap " method="post">
<p><font face="Arial" size="2"><b>Num ber of Users Required :</b></font>
<input type=text value="1" name="hsunits1" onkeydown="find Price()"
onKeyUp="filter NonNumeric(this ); findPrice()" onkeypress="fin dPrice()"
size="4" style="font-weight:bold; text-align:center;">
<input type=text onfocus="this.b lur()" name="hsresult1 " size="24"
style="border:0 ; font-weight:bold;">
<br><font face="Arial" size="2"><b>Num ber of Users Required :</b></font>
<input type=text value="1" name="hsunits2" onkeydown="find Price()"
onKeyUp="filter NonNumeric(this ); findPrice()" onkeypress="fin dPrice()"
size="4" style="font-weight:bold; text-align:center;">
<input type=text onfocus="this.b lur()" name="hsresult2 " size="24"
style="border:0 ; font-weight:bold;">
</form>
<form name="form1">
<p align="left"><f ont
color="black">< strong>Total Sales
&nb sp; &nb sp; &nb s
p; & nbsp; &nbs p; & nbsp; &nbs p; <input
type="text" name="hstotal" value="0.00" size="16"
onchange="Compu teForm()"
style="font-family:Arial; font-style:normal;
font-weight:bolder; font-size:11pt; color:white; background-color:black;"
language="JavaS cript"></strong></font></p>
</form>
</html>
Comment