Form field not being updated

I have a web form where the user has a choice of selecting either Credit Card U.S. or Credit Card International.  The problem with the code is that the field "Convenience fee (2.3% for CC)" is not being updated with the correct amount when the user selects Credit Card - U.S. In other words, it still shows a "0". However it works with Credit Card - International where the correct amount is shown (please refer to attached screen shots). I am not sure what is causing the error. I have also attached the code. I would appreciate your help.
Credit-Card-Internationa.png
Credit-Card-U.S..png
payment.html
geeta_m9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aboo_sCommented:
var fee_pct = 2.3;
function update_total_add (idx, input_obj) {
  if (input_obj.value > 0) {
    $('#subtotal')[0].value = 1*$('#subtotal')[0].value + 1*input_obj.value;
    if ($('#pay_method')[0].selectedIndex == 0) {
      $('#fee')[0].value = Math.round(fee_pct*$('#subtotal')[0].value)/100.0;
    } else {
      $('#fee')[0].value = '0';
    }


change:

if ($('#pay_method')[0].selectedIndex == 0 || $('#pay_method')[0].selectedIndex == 1) {
      $('#fee')[0].value = Math.round(fee_pct*$('#subtotal')[0].value)/100.0;
    } else {
      $('#fee')[0].value = '0';
    }
    $('#total')[0].value = 1*$('#subtotal')[0].value + 1*$('#fee')[0].value;
  }
}
geeta_m9Author Commented:
I made the change, but I am obtaining a syntax error  on the "if" statement.
geeta_m9Author Commented:
I had to change it to this format for the error to go away

if (($('#pay_method')[0].selectedIndex == 0) || ($('#pay_method')[0].selectedIndex == 1)){

Is this the correct syntax?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

geeta_m9Author Commented:
I tried your suggestion, but it is still not working.
aboo_sCommented:
please try this:
function update_total_add (idx, input_obj) {
  if (input_obj.value > 0) {
    $('#subtotal')[0].value = 1*$('#subtotal')[0].value + 1*input_obj.value;
    if (($('#pay_method')[0].val() == 2) || ($('#pay_method')[0].val() == 1) ) {
      $('#fee')[0].value = Math.round(fee_pct*$('#subtotal')[0].value)/100.0;
    } else {
      $('#fee')[0].value = '0';
    }
    $('#total')[0].value = 1*$('#subtotal')[0].value + 1*$('#fee')[0].value;
  }
}

or this:

function update_total_add (idx, input_obj) {
  if (input_obj.value > 0) {
    $('#subtotal')[0].value = 1*$('#subtotal')[0].value + 1*input_obj.value;
    if (($('#pay_method').val() == 2) || ($('#pay_method').val() == 1) ) {
      $('#fee')[0].value = Math.round(fee_pct*$('#subtotal')[0].value)/100.0;
    } else {
      $('#fee')[0].value = '0';
    }

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
geeta_m9Author Commented:
It is working now, thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.