Skip to content
Advertisement

How do I change this variable using radio buttons?

Hello I’ve been tearing my hair out over this all last night and this morning, I have a radio button set with 3 options and I have a variable called “Minimum_fare”. I’m trying to write javascript that will set the variable “minimum_fare” to a different number depending on which radio button is selected.

JavaScript
JavaScript

I’ve looked at dozens of answers on stackexchange and tried implementing everything I can think of but I’m still stuck. How can I get the radio button to set the minimum fare variable?

Snippet updated

Advertisement

Answer

Does this answer your question? (reference)

JavaScript
JavaScript

I have added function change_MinimumFare to both snippets since it requires full code to run

Edited to Add: added parseFloat function since calc_fare is a float variable

Advertisement