0
Good morning, good afternoon and good evening.
I have a code that includes a checkbox and radio listing for my user to select the desired operation, but when marking a radio it should not be able to select any check other than the radio line, but I’m not able to make this block for the other lines, it works only in the first row of my table and I don’t have much knowledge in JS. The function that does not work as imagined is the validationMawb.
function testaCheck(idMaster) {
var inputs, i, checados = 0;
inputs = document.getElementsByTagName("input");
for (i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
if (inputs[i].checked == true) {
checados++;
document.getElementsByName('DS_MD' + idMaster).value = idMaster;
$("#formSelectMAWB").find("#masterDireto").val(idMaster);
}
}
}
if (checados > 1) {
uncheckAll(inputs);
document.getElementsByName('DS_MD' + idMaster).value = null;
$("#formSelectMAWB").find("#masterDireto").val(null);
}
};
function uncheckAll(inputItems){
alert("MAWB não selecionado ou MAWB diferente do Direto. Favor refazer a seleção");
for (i = 0; i < inputItems.length; i++) {
inputItems[i].checked = false;
}
}
function validaMawb(){
var d = document.getElementsByName('DS_MD' + idMaster).value();
var m = document.getElementById('idMAWB').value;
if(d.value !== m.value){
uncheckAll(inputs);
document.getElementsByName('DS_MD' + idMaster).value = null;
$("#formSelectMAWB").find("#masterDireto").val(null);
}}
<div class="linhaLista">
<div class="campoLista TamanhoCampoLista7" title="">
<div class="input-control span1 floatForm-left">
<label class="input-control radio">
<input type="radio" name="idMAWB" id="idMAWB" value="<%=ID_CD_MAWB%>" onClick="selecionaMAWB(this.value);">
<span class="helper"><%=DS_MAWB%></span>
</label>
<label for="DS_MD<%=ID_CD_MAWB%>">
<input type="checkbox" name="DS_MD<%=ID_CD_MAWB%>" id="masterDireto<%=ID_CD_MAWB%>" onClick="testaCheck(<%=ID_CD_MAWB%>);validaMawb();">
<span class="helper"> Master Direto </span>
</label>
</div>
</div>
You can’t repeat id’s, otherwise you’ll always get the first one.
– Sam
So where I have the script from validaMawb I would have to use another means to call the comparison variables?
– Pietro Rey
Which div is repeating?
– Sam
To
<div class="input-control span1 floatForm-left">
which is the third div always repeats itself by being part of the listing construction.– Pietro Rey
I would have to use another medium. But your code is all wrong. You have to redo it almost all, as I see it.
– Sam
I get it Sam, if you can give me a direction where to start or some place to study better thank you, I’m starting in js
– Pietro Rey