hmmm - yeah, they all seem same, same but different. Maybe you should look at the pizza assignment?
Anyway. To answer your question, there are a few ways that I can think of. One bad and simple, one good and a little more complicated, one simple but inflexible.
The first would be to set a global variable with the default value and then have onclicks on your radio buttons which would change the value of that variable to the value of the radio. But being that the use of globals is discouraged and it's better not to use them if you don't have to....
The second way is that in the function that requires that value, to get a collection of your radios. Assuming you have named them "units", this can be done easily when they are in a form like this:
Code:
var rads=document.forms[0].units
when they are not in a form you would do something like this:
Code:
var rads=document.getElementsByName("units")
then you loop through rads, find out which one is checked and set a local variable to its value.
The third way works if you know that there will only ever be two radios (like in the litres/gallons example). Here you can use the ternery operator. You give your default setting and ID and then just check if it is checked:
Code:
var quantity=document.forms[0].litres.value;
var subtot=document.getElementById("litres").checked?quantity:quantity*4;
but like I say, that only works for two radios.