-2
I have this form that is of a box office in html, but I want it to work using javascript, when clicking the button of + or - to change the quantity and change the total value.
I looked it up and saw the tag output I was testing but I could not perform a good implementation with the buttons...
the html code I have is as follows:
<tr class="linha-meio borda-topo">
<td class="divisao-direita">CRIANÇA (3 - 12 ANOS)</td>
<td>13,78 €</td>
<td class="alinhar-direita">
<button class="botao-quantidade">➖</button>
<a class="quantidade">0</a>
<button class="botao-quantidade">➕</button>
</td>
</tr>
<tr class="linha-meio">
<td class="divisao-direita">ADULTO (13 - 64 ANOS)</td>
<td>21,38 €</td>
<td class="alinhar-direita">
<button class="botao-quantidade">➖</button>
<a class="quantidade">2</a>
<button class="botao-quantidade">➕</button>
</td>
</tr>
<tr class="borda-fundo">
<td class="divisao-direita">SÉNIOR (+65 ANOS)</td>
<td>15,20 €</td>
<td class="alinhar-direita">
<button class="botao-quantidade">➖</button>
<a class="quantidade">0</a>
<button class="botao-quantidade">➕</button>
</td>
</tr>
<tr class="nao-mudar-cor-1">
<td></td>
<th class="alinhar-direita">Total:</th>
<td class="alinhar-direita">42.76€ c/iva</td>
</tr>
</table>
If you can help, I’m new to Java
"I saw the tag output" tag output? I don’t know this and I didn’t see your question, can you put an example? I was curious. About your question, you have created some code
javascript
? create a Function associated with the "click" event of the buttons, and according to the button (+/-) you sum or subtract the value and change in the "quantity" element. By the way, where does the amount need to be a link? could not be a span or div?– Ricardo Pontual
@Ricardopunctual I saw on this link link I can do a few things, but I don’t think it’s ideal here... I have already been able to put the quantity to work with the answer below, it is only missing to calculate the total according to the selected quantity
– Tiago Fernandes