Order Form with graduated prices

  • jbuchberger
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 0

jbuchberger created the topic: Order Form with graduated prices

I like to create an order form with graduated prices depending on a quantity input. But my form doesn't work. Any help is welcome!

The idea:
By entering the quantity in a text field the form will display a different price for different quantities iin a price field. A total field will display the result of the multiplication of the quantity field with price field.

The prices:
Price for 1 up to 5 pieces > 39,90
Price for 6 up to 10 pieces > 34,90
Price for 11 up to 25 pieces > 29,90
Price for 26 and more pieces > 24,90

1. Quantity Input Field
Typ: Number Input
Name: quantity
Validate: ff_integeramount
Actionscript: on change
function ff_quantity_action(element, action)
{
ff_getElementByName('total').value =
Number(ff_getElementByName('quantity').value) *
if (Number(ff_getElementByName('quantity').value) >= 1 && Number(ff_getElementByName('quantity').value) <= 5 ) {
ff_getElementByName('price').value = "39,90";
}
elseif (Number(ff_getElementByName('quantity').value) >= 6 && Number(ff_getElementByName('quantity').value) <= 10 ) {
ff_getElementByName('price').value = "35,90";
}
elseif (Number(ff_getElementByName('quantity').value) >= 11 && Number(ff_getElementByName('quantity').value) <= 25 ) {
ff_getElementByName('price').value = "29,90";
}
else (Number(ff_getElementByName('quantity').value) >= 26) {
ff_getElementByName('price').value = "24,90";
}
}

2. Price Field
Type: Text
Advanced: Only Read
Actionscript: On change
function ff_price_action(element, action)
{
ff_getElementByName('total').value =
Number(ff_getElementByName('quantity').value) *
if (Number(ff_getElementByName('quantity').value) >= 1 && Number(ff_getElementByName('quantity').value) <= 5 ) {
ff_getElementByName('price').value = "39,90";
}
elseif (Number(ff_getElementByName('quantity').value) >= 6 && Number(ff_getElementByName('quantity').value) <= 10 ) {
ff_getElementByName('price').value = "35,90";
}
elseif (Number(ff_getElementByName('quantity').value) >= 11 && Number(ff_getElementByName('quantity').value) <= 25 ) {
ff_getElementByName('price').value = "29,90";
}
else (Number(ff_getElementByName('quantity').value) >= 26) {
ff_getElementByName('price').value = "24,90";
}
}

3. Total field
Type: Text
Advanced: Only read
Actionscript: None action
function ff_total_action(element,action)
{
ff_getElementByName('total').value = 0;
{
ff_getElementByName('total').value =
Number(ff_getElementByName('quantity').value) *
if (Number(ff_getElementByName('quantity').value) >= 1 && Number(ff_getElementByName('quantity').value) <= 5 ) {
ff_getElementByName('price').value = "39,90";
}
elseif (Number(ff_getElementByName('quantity').value) >= 6 && Number(ff_getElementByName('quantity').value) <= 10 ) {
ff_getElementByName('price').value = "35,90";
}
elseif (Number(ff_getElementByName('quantity').value) >= 11 && Number(ff_getElementByName('quantity').value) <= 25 ) {
ff_getElementByName('price').value = "29,90";
}
else (Number(ff_getElementByName('quantity').value) >= 26) {
ff_getElementByName('price').value = "24,90";
}
}
}

Any ideas? Best regards;
Jürgen
#237987
  • Posts: 3128
  • Karma: 105
  • Thank you received: 413

mihaela replied the topic: Order Form with graduated prices

Hello,

I understand how you want this to work.

You are on the right track, but you are doing a few things wrong.

First, this is incorrectly formatted:
ff_getElementByName('total').value =
Number(ff_getElementByName('quantity').value) *
if (Number(ff_getElementByName('quantity').value) >= 1 && Number(ff_getElementByName('quantity').value) <= 5 ) {
ff_getElementByName('price').value = "39,90";

You shouldn't be multiplying by the "if" statement. The "if" statement should come at the beginning, like this:
if(Number(ff_getElementByName('quantity').value) >= 1 && Number(ff_getElementByName('quantity').value) <= 5) {
	ff_getElementByName('total').value = Number(ff_getElementByName('quantity').value) * 39.90;
	ff_getElementByName('price').value = "39,90";
}
What this will do is it will multiply the quantity with 39.90 (if 1 <= quantity <=5), and put the calculated amount in the "total" field.
Also, it will fill the "price" field with the amount "39,90".

Add an "if" condition for each of the cases.

Also, there is no need to write Actionscript for the "price" and "total" field since they are read-only and calculation will be made in Actionscript od the "quantity" field.

Let me know whether you have managed to make the calculation work properly with the code suggested.

Regards,

Mihaela
#237991
Moderators: ForumSupport
Time to create page: 0.043 seconds

We Are Doing Our Part

Massive discounts on all of our extension subscription plans to help you and your business in these times.

Get Your Subscription Here

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

We are doing our part and support your business with extremely low prices -- For example 6-Months-Subscription for only $9 USD. For as long as necessary.

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!