I would like to see if any checkbox in a particular div has been selected, so as to proceed with a multiphase form I am working on. Currently whether a checkbox is selected or not, I am getting the alert "Tile selected".
HTML code
<div class='material' id='material1'>
<a class='product'><div class='tiles_bg' style='background:url(media/images/tile2.jpg);'><input class='select_all' id='tile' type='checkbox' name='1marm' value='Verde Guatemala'></div><p>Verde Guatemala</p></a>
<a class='product'><div class='tiles_bg' style='background:url(media/images/tile1.jpg);'><input class='select_all' id='tile' type='checkbox' name='1marm' value='Bianco Carrara'></div><p>Bianco Carrara</p></a>
</div>
<button type="button" class="nasta" onClick="processStep1()">Nasta</button>
jquery code
var tile;
function _(x){
return document.getElementById(x);
}
function processStep1(){
tile = _("tile").value;
if(!("tiles_bg input:checked").length) {
/* _("step1").style.display = "none";
_("step2").style.display = "block"; */
alert(tile);
} else {
alert("Tiles selected");
}
}
Aucun commentaire:
Enregistrer un commentaire