Q:

How to know which radio is checked from a fieldset

I have the following code:
    <fieldset id="dificuldade">
        <legend>Dificuldade:</legend>
        <input type="radio" name="dificuldade" value="facil"> Fácil </input>
        <input type="radio" name="dificuldade" value="medio"> Médio </input>
        <input type="radio" name="dificuldade" value="dificil"> Difícil </input>
    </fieldset>

    <fieldset id="tipo">
        <legend>Tipo de jogo:</legend>
        <input type="radio" name="Tipodejogo" value="somar"> Somar </input>
        <input type="radio" name="Tipodejogo" value="subtrair"> Subtrair </input>
        <input type="radio" name="Tipodejogo" value="dividir"> Dividir </input>
        <input type="radio" name="Tipodejogo" value="multiplicar"> Multiplicar </input>
    </fieldset>

    <input type="button" value="Começa" id="button" ></input>
</form>

and here is the jsfiddle with both the html and the js http://jsfiddle.net/3bc9m/15/ . I need to store the values of the 2 fieldset so I, depending on the values picked can generate a game, but my javascript isn't returning any of them. What is wrong? I've been told that JQuery is much easier but i can't use it.

A:

Your code on jsFiddle seems to be working fine for the most part.  The only thing was that the elements output and output2 don't exist on the page.
So this code that was supposed to display the selected values wasn't working:
document.getElementById('output').innerHTML = curr.value;
document.getElementById('output2').innerHTML = tdj.value;

The part that actually retrieves the selected values is working fine.
Just add those two elements to the page, like this:
<p>Selected Values:</p>
<div id="output"></div>
<div id="output2"></div>

An updated jsFiddle can be found here.
EDIT
If a radio button from only one of the sets is selected, the code fails.  You could use this code to find the selected values instead:
document.getElementById('button').onclick = function() {

    var dif = document.getElementsByName('dificuldade');
    var tip = document.getElementsByName('Tipodejogo');

    var difValue;
    for (var i = 0; i < dif.length; i++) {
        if (dif[i].type === "radio" && dif[i].checked) {
            difValue = dif[i].value;
        }
    }

    var tipValue;
    for (var i = 0; i < tip.length; i++) {
        if (tip[i].type === "radio" && tip[i].checked) {
            tipValue = tip[i].value;
        }
    }

    document.getElementById('output').innerHTML = difValue;
    document.getElementById('output2').innerHTML = tipValue;
};​

An updated jsFiddle is here.

