1
My need to allow: With the radio selection he can choose or not the checkbox corresponding to the radio ID. And if the user selects a checkbox in addition (>1) I send an Alert informing that there was a second check selection and clear the fields. However I am not able to clear the checkbox after the second click.
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) {
alert("Só pode haver um item selecionado.");
inputs[i].checked = false;
}
}
}
};
<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%>)">
<span class="helper"> <%=ID_CD_MAWB%> </span>
</label>
What is the relation of the ASP in the problem?
– Sam
I left ASP because I don’t know if there is a difference between JS that is used with ASP for use with other languages. I am learning about ASP and JS at the stage where I am.
– Pietro Rey
Well, it seems to me that your problem is Javascript only, so I see no reason to use the tag [tag:]
– Sam
Got it, so I removed the Asp tag. Thanks for the tip Sam.
– Pietro Rey
That function
selecionaMAWB()
is what? It doesn’t have it in the code.– Sam
The
selecionaMAWB()
is to bring the value that corresponds to ID_CD_MAWB is something that already existed in the system since creation. Ex: ID_CD_MAWB - 17 ; MAWB - 417 2541 5571– Pietro Rey