This is my first post here, so hello! I'm an intermediate coder looking for a bit of help, and I would appreciate it if someone could help me figure out where I can improve.
I'm coding in AS3 and have some script that I'm using to calculate a minimum credit card payment for different types of credit cards. I have a space for a user to enter in their balance (bal_text), three radio buttons (named sig, plat, and ret) to select the card type, and a submit button (calculate_btn). I've used Math.round to round out my payments to whole dollar amounts. If the minimum payment due is less than $35, the payment will display as $35. I have a dynamic text field, min_text, that displays the payment due. Here's my script:
ActionScript Code:
import flash.events.MouseEvent;
stop ();
calculate_btn.addEventListener(MouseEvent.CLICK, calcMinDue);
function calcMinDue(e:MouseEvent):void {
var minDue : Number;
if(sig.selected = true) {
minDue = Number(bal_text.text) * .1;
minDue = Math.round(minDue);
if (minDue < 35) {
minDue = 35;
}
min_text.text = "$" + String(minDue);
}
else if(plat.selected = true) {
minDue = Number(bal_text.text) * .05;
minDue = Math.round(minDue);
if (minDue < 35) {
minDue = 35;
}
min_text.text = "$" + String(minDue);
}
else if(ret.selected = true) {
minDue = Number(bal_text.text) * .05;
minDue = Math.round(minDue);
if (minDue < 35) {
minDue = 35;
}
min_text.text = "$" + String(minDue);
}
}
The math side of things is working fine (which, for me, is a big win). All the payments calculate and work the way I expect them to. The problem is that if I select any radio button other than "sig," Flash changes my selection to the "sig" radio button and performs the proper calculation when I press my calculate_btn.
Any thoughts on what's going on here?