views:

108

answers:

3

Some simple HTMl, I've added spans for styling, should I be using labels instead? It's meant to only allow one selected at a time. What am I doing wrong? I am codeblind :P

JSfiddle here.

Thanks.

+4  A: 

A radio group is created by a having a number of radio buttons with the same name.

You have a number of radio groups, each containing one button.

You shouldn't add labels for styling, but you should add labels for associating the label of a radio button with the radio button.

David Dorward
Wasn't aware of that, thanks :)
Kyle Sevenoaks
+1  A: 

you need to group the radio buttons as such:

<form>
    <span id="betalfakturavalg">
        <input type="radio" name="group1" title="Valg Faktura"
        onclick="document.getElementById('betalfakturavalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Faktura - For bedrifter  
    </span>
    <br>
    <span id="betalkortvalg">
        <input type="radio" name="group1" title="Valg Kreditkort"
        onclick="document.getElementById('betalkortvalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Kreditkort - For alle privatpersoner
    </span>
</form>
Mick Walker
+1  A: 

Use single name in the radio button,

<form>
    <span id="betalfakturavalg">
        <input type="radio" name="betalfakturavalg" title="Valg Faktura"
        onclick="document.getElementById('betalfakturavalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Faktura - For bedrifter  
    </span>
    <br>
    <span id="betalkortvalg">
        <input type="radio" name="betalfakturavalg" title="Valg Kreditkort"
        onclick="document.getElementById('betalkortvalg').style.cssText='border-color:#85c222; background-color:#E5F7C7;';" /> Kreditkort - For alle privatpersoner
    </span>
</form>
Karthik