Hi All,
I am trying to assign a certain price to radio inputs with the same name so that only one can be selected at a time. If the user clicks on one of the radios then the price, that’s already been set, will change and be updated with the new price.


I have three radio inputs that will need to have values assigned to them.
Any ideas? Everything I have been able to find online for this has either not worked in my testing or was prehistoric code.

Any help is greatly appreciated.

Update:
I was able to solve the issue, but I had to convert the radios back to check-boxes, and then write a separate function to change the .prop so that when another was checked the others would turn false. Once I did that I used the parseFloat() to solve the addition issue and assign it to the new variable.
I then had to assign the values I wanted each checkbox to have under the value=”” tag in my html input element, and there we go. Now when I check each checkbox it auto sums the values and adds them to the base values. All I had left to do was style the check-boxes as buttons and make sure that when the button is pushed the corresponding checkbox was also checked for my form and task complete. Hope this helps anyone else with this issue.
Can you explain your question better and/or put some pseudo code/html in that shows your beginning state and desired end state? I think I understand what you’re putting down, but not quite.
this.value is what you are looking for. It will give you the value of the selected radio button.
Here’s a sample code
$(‘input[type=radio]’).change(function(){
// Get your price element and set it’s val or text to this.value, for eg
$(‘#price’).val(this.value);
});
I will try this in the morning – us tz – and let you know how it goes. Thanks for the suggestion. This is very close to a solution I’ve been trying. Hope it works!
Members
Online

source