JSFiddle - React, Tailwind, and code Playground
HTML
<TR><H3 class=ms-standardheader><NOBR>Installation de chantier et accès:</NOBR></H3></TD>
<TD style="WIDTH: 89px"><SPAN id=optChgPriority><SPAN>
<TABLE cellSpacing=1 cellPadding=0>
<TBODY>
<TR>
<TD><SPAN title=suffisant class=ms-RadioText><INPUT name=ctl00$m$g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe$ff121$ctl00$RadioButtons id=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl00 type=radio value=ctl00 jQuery111106499962444293681="7"><LABEL style="DISPLAY: none" for=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl00 jQuery111106499962444293681="153">suffisant</LABEL><SPAN title="plutôt insuffisant" class=ms-RadioText><INPUT name=ctl00$m$g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe$ff121$ctl00$RadioButtons id=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl01 type=radio value=ctl01 jQuery111106499962444293681="9"><LABEL style="DISPLAY: none" for=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl01 jQuery111106499962444293681="154">plutôt insuffisant</LABEL></SPAN><SPAN title=insuffisant class=ms-RadioText><INPUT name=ctl00$m$g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe$ff121$ctl00$RadioButtons id=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl02 type=radio value=ctl02 jQuery111106499962444293681="10"><LABEL style="DISPLAY: none" for=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl02 jQuery111106499962444293681="155">insuffisant</LABEL></SPAN><SPAN title="non applicable" class=ms-RadioText><INPUT name=ctl00$m$g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe$ff121$ctl00$RadioButtons id=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl03 type=radio CHECKED value=ctl03 jQuery111106499962444293681="11"><LABEL style="DISPLAY: none" for=ctl00_m_g_afe4ac08_172d_4f80_bb3d_e7191f2d0afe_ff121_ctl00_ctl03 jQuery111106499962444293681="156">non applicable</LABEL></SPAN></SPAN></TD></TR>
<TR>
<TD></TD></TR>
<TR>
<TD></TD></TR>
<TR>
<TD></TD></TR></TBODY></TABLE></SPAN></SPAN></TD>
<TD style="WIDTH:...
JavaScript
var rep= {"ctl00": 0,"ctl01": 0,"ctl02": 0,"ctl03": 0};
var moyenne = 0;
$(function() {
init_rep();
update_result();
$('input[type=radio]').not("#optChgPriority11 input[type=radio]").mousedown(function(){
var radio = $(this).prop("name");
if($("input[name='"+radio+"']:checked").length != 0) {
var old_val = $("input[name='"+radio+"']:checked").val();
rep[old_val]--;
}
}).change(function() {
var radio = $(this).prop("name");
var new_val = $("input[name='"+radio+"']:checked").val()
rep[new_val]++;
update_result()
});
})
//Nouvelle fonction pour initialisation de rep
function init_rep() {
//Ici on récupère les input radio qui sont checked, sauf le 11ème
$.each($('input[type=radio]:checked').not("#optChgPriority11 input[type=radio]"), function() {
//on récupère la valeur (ctl03 par exemple)
var value = $(this).val();
//On incrémente la valeur de "rep" correspondant
rep[value]++;
});
}
function update_result() {
$("#TS").empty().html(rep["ctl00"]);
$("#S").empty().html(rep["ctl01"]);
$("#I").empty().html(rep["ctl02"]);
$("#TI").empty().html(rep["ctl03"]);
var max = maxvalue();
$("#optChgPriority11 input[type=radio][value='"+max+"']").prop("checked", true)
}
function maxvalue() {
var max = 0;
var indexmax="";
$.each(rep, function(index,value) {
if(value > max) {
max=value;
indexmax=index;
}
})
return indexmax;
}