SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: JS picking wrong type
Threaded View
-
Jul 20, 2007, 12:56 #1
- Join Date
- Feb 2004
- Location
- Ashburn, VA
- Posts
- 47
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
JS picking wrong type
Can anyone tell me if there is something wrong with my code? I have dropdown menu that lists payment methods. If the user selects one of the credit cards on the list, I want the JS to calculate the fee and show in another form field on screen.
For some reason, no matter what is selected it keeps using the default value for the calculation. HELP!!
Here is the js code that fires when a Calculate button is clicked.
Code:function checkCC(){ var type = document.getElementById("paymentmethod"); switch (type) { case 'Visa': var perct = .03; break case 'American Express': var perct = .0325; break case 'Master Card': var perct = .003; break default: var perct = 5; } cogs = document.mainform.cogs.value document.mainform.creditfee.value = (cogs*perct).toFixed(2); }
Bookmarks