1
my question is: I have a div with a checkbox and another with an image, I would like that after the user marks the div with checkbox and clicks on a confirmation button, my js function checks if the checkbox is checked and if it is it compares the checkbox id attribute is equal to the image value and if it is it hides the checkbox and shows the image.
The html is:
<div class="toggle div-inline" style="display: ">
<input type="checkbox" id="consultar_acervo" name="toggle"> <span>Consultar Acervos</span>
<label for="consultar_acervo"></label>
</div>
<div class="column zoom" style="display:none">
<a href="https://siga.ufvjm.edu.br/index.php?module=biblioteca&action=main:pesquisasimples" data-toggle="tooltip" data-placement="top" title="Consultar Acervo" target=“_blank”>
<img src="../images/img_nature.jpg" alt="Fjords" style="width:100%" value="consultar-acervo" id1= "icons">
</a>
<div class="col-sm-1">
<button type="button" class="btn btn-success" id="aplica" onclick="checar()"> Aplicar</button>
in javascript I have already managed to do the function that checks if the checkbox is checked, I know that this comparison of attributes is done inside the if but do not know how to do it, vcs can help me?
The Js file
function checar(){
var checa = document.getElementsByName("toggle");
for (var i=0;i<checa.length;i++){
if (checa[i].checked == true){
// CheckBox Marcado... Faça alguma coisa...
} else {
// CheckBox Não Marcado... Faça alguma outra coisa...
}
}
}
Ids are unique - Each page can have only one element with that ID.
– user60252
Hey, Leo Caracciolo, thanks for your help. I expressed myself badly, in vdd I want to compare the 'checkbox id' with the 'image value', these two can have iguai values or tbm not?
– MStos
Image has no value
– user60252
If I use 'name', it is valid?
– MStos
How to check if everything is hidden with display: None?
– Sam
Can be with jquery?
– user60252
It was my dvd error, the check starts only with " display= ". Can yes Leo Caracciolo
– MStos