Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Conditional if..else statements populating another field

$
0
0

Hi,

 

new to the forum. A big shout out to all those that help people like me. It is greatly appreciated not only in solving the problem but helping us to learn as well.

 

I have looked at other questions and cannot quite get what I am looking for. Java script seems to make my mind go what the...

 

scenario:

I have a credit card form and I want to calculate a surcharge amount on the transaction.

Type of card (field 'card') is chosen from a dropdown box and the value can either be Visa, MC or Amex, with the export value either 1,2 or 3 respectively.

The transaction amount is entered into field 'amount'. On Exit of the field 'amount' I want the field 'surcharge' to automatically be populated with a calculation. That calculation being:

if 'card' = 1 then 'surcharge' = 'amount' * .01

else

if 'card' = 2 then 'surcharge' = 'amount' * .03

else

if 'card' = 3 then 'surcharge' = 'amount' * .05

 

I have one more field 'total' which will be Value of the sum 'amount', 'surcharge'.

 

The other part is if the wrong card was chosen first (eg sales person chose Visa but it should have been Amex) I would want the field 'surcharge' to automatically recalculate On Exit of that field.

 

Any assistance, guidance would be greatly appreciated.

 

thanks

 

Kudurider


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>