mardi 18 août 2015

javascript hide show element checkbox

I have 8 check boxes, only one of these are checked by default.

When you click the unchecked ones twice the table(that the checkboxes are linked too) hide.

Ideally i need the unchecked ones to be hidden by default and the checked one to be shown by default. Then show then checked etc.

Here is the javascript code

function showhide(el, target) {
    document.getElementById(target).style.display = el.checked ? 'block' : 'none';
}

And here is the html

<th><input onclick="showhide(this, '1')" type="checkbox"> 1 </th>
<td><input onclick="showhide(this, '3')" type="checkbox"> 3 </td>




Aucun commentaire:

Enregistrer un commentaire