Jump to content

[SOLVED] Possible with javascript?


Shamrox

Recommended Posts

I have a dropdown list on a form that lists different types of credit cards. I also have a form field that is called charge card fee and I would like this to be populated with a $ amount based on what card was selected from the dropdown. Each card has a different fee that is a % of the sale price. So there is a third field of Price that is involved.

Is there a way to have the fee field calculated and populated using javascript?

 

Any help is appreciated. Thanks.

Link to comment
https://forums.phpfreaks.com/topic/47921-solved-possible-with-javascript/
Share on other sites

function checkCC(){

var type  = document.getElementById(this);

var perct = 0;

switch(type){

case 'visa':

perct = .25;

break;

case 'mastercard':

perct = . 28;

break;

}

document.getElementById('id of field that holds the percent value, this could be a hidden field, just give it an id').value = perct;

}

 

<select onchange = "checkCC(this)"></select>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.