Display the Value of the Checkbox. The message changes while the user checked or unchecked the checkbox. I have this code but it is arranged in alphabetical manner everytime i check/uncheck a box which should not be. It should be displayed in a manner on how the user selected the checkboxes.
Javascript Code:
<script>
function callMe(x)
{
var changeableTags=document.getElementsByClassName(x.getAttribute("title"));
if(x.checked == true)
{
for(i=0; i<changeableTags.length; i++)
{
changeableTags[i].style.display="initial";
}
}
else{
for(i=0; i<changeableTags.length; i++)
{
changeableTags[i].style.display="none";
}
}
}
</script>
HTML Code:
<body>
<input type="checkbox" title="nr_1" name="abccheck" checked onChange="callMe(this)"> A</input> <br>
<input type="checkbox" title="nr_2" name="abccheck" checked onChange="callMe(this)"> B</input> <br>
<input type="checkbox" title="nr_3" name="abccheck" checked onChange="callMe(this)"> C</input> <br>
<p class="nr_1" style="display:initial">A </p>
<p class="nr_2" style="display:initial">B </p>
<p class="nr_3" style="display:initial">C </p>
</body>
Aucun commentaire:
Enregistrer un commentaire