1

So I've got this :

<table id="table2" border="1">
<tr>
<td id="table2"><center><B>A</B></center></td>
<td id="table2"> <span id="clicks">  0</span></td>
<td id="table2"><center><B>B</B></center></td>
<td id="table2"><span id="clicksb">  0</span></td>
<td id="table2"><center><B>C</B></center></td>
<td id="table2"><span id="clicksc">  0</span></td>
<td id="table2"><center><B>D</B></center></td>
<td id="table2"><span id="clicksd">  0</span></td>
</tr>

and a lot of tables that add a +1 to those zeros, depending if you choose the option A,B,C or D in any of those, I don't know how to just be able to choose one option of the ones available on the "imaginary" table, as well as being able to choose between those options and give add or remove that +1 depending on the choice.

https://codepen.io/holajosd/pen/bQapaB is the result of my actual work

I only managed to be able to select the options (buttons) and make them add a +1 to their "clicks, clicksb.... " id.

So in resume I need something that makes a person able to click only one of the buttons at the same time, but be able to click another button, this action unblock the last button from the same table and dont count that +1 to the final counter (or do a -1 to make it equal), hope I expressed myself.

  • Have you considered using radio buttons instead of regular buttons? – user247702 Nov 26 '18 at 17:09
  • Yes! It should make it way easier but it looks uglier at the same time(at least it does to me), unless you can modify a radio button and make it look exactly like the other one, but I still would have to do some unknown javascript to dont stack that +1 after a change of mind between options. – Jorge Hurtado Nov 26 '18 at 17:12
  • _but it looks uglier at the same_ you cant use css? – Smollet777 Nov 26 '18 at 17:35

1 Answers1

0

Give each checkbox a unique ID and set the checked property. See this answer for detail: https://stackoverflow.com/a/8206573/10586735

EDIT:

You can also add the disabled property to the other checkboxes when one is clicked. It is done the same way as the checked property, just using

document.getElementById("checkbox0102").disabled = true;
Thomas N
  • 1
  • 1