Auto-eval radio boutons

with Limesurvey

by toubia95

HTML

<table summary="ÉVALUATION DU TRAVAIL EN MILIEU PROFESSIONNEL

N°Etudiant : 31213551
NOM : Marie AGOSSOU
Parcours : P1
Stage du 23/06/2014 au 12/09/2014
Lieu : TECHNOSOL NORMANDIE ZI Ouest Rue de la Vigne 14650 CARPIQUET
Tuteur : M. Gilles TOUBIANA
Intitulé du stage : Reconnaissance de sol, réalisation et interprétation d'essais géotechniques, suivi des dossiers d'études, participation à la rédaction des rapports. - an array type question" class="question">
    <colgroup class="col-responses">
        <col width="40%" class="col-answers">
            <col width="15%" class="odd">
                <col width="15%" class="even">
                    <col width="15%" class="odd">
                        <col width="15%" class="even">
    </colgroup>
    <thead>
        <tr>
            <td>&nbsp;</td>
            <th>A
                <br>Excellent
                <br>Travail</th>
            <th>B
                <br>Très bon
                <br>Travail</th>
            <th>C
                <br>Bon
                <br>Travail</th>
            <th>D
                <br>Travail
                <br>insuffisant</th>
        </tr>
    </thead>
    <tbody id="javatbd93754X5413X60806SQ001">
        <tr class="array2">
            <th class="answertext">Intégration (communication &ndash; travail en équipe)
                <input type="hidden" value="" id="java93754X5413X60806SQ001" name="java93754X5413X60806SQ001">
            </th>
            <td class="answer_cell_00A">
                <label for="answer93754X5413X60806SQ001-A">
                    <input type="radio" onclick="checkconditions(this.value, this.name, this.type)" title="A Excellent Travail " id="answer93754X5413X60806SQ001-A" value="A" name="93754X5413X60806SQ001" class="radio" checked>
                </label>
            </td>
            <td class="answer_cell_00B">
                <label for="answer93754X5413X60806SQ001-B">
                    <input type="radio" onclick="checkconditions(this.value,...

JavaScript

$('input[type=radio]').change(function () {
    var i=1, selector="", res="", vala = 0,
        valb = 0,
        valc = 0,
        vald = 0;
    for (i = 1; i < 10; i++) {
        selector = "93754X5413X60806SQ00" + i;
        res = $("[name='" + selector + "']:checked").val();
        if (res !== undefined) {
            if (res == "A") {
                vala++;
            } else if (res == "B") {
                valb++;
            } else if (res == "C") {
                valc++;
            } else if (res == "D") {
                vald++;
            }
        }
    }
    $('#test1').val(vala);
    $('#test2').val(valb);
    $('#test3').val(valc);
    $('#test4').val(vald);
});