2
I’m having some difficulties with Javascript. I want to add some fields of my "Input List" and multiply others by clicking on a "Calculate button", thus informing a value in an "Input Text". Nothing else I do has worked out, please if anyone can help me.
Preço:
<input type="text" name="preco"><br />
<button>Comprar</button>
<form id="pizza3">
<p>Tamanho da Pizza:</p>
<input list="tmhpizza" name="tmhpizza" required />
<datalist id="tmhpizza">
<option value="Brotinho">R$20,00</option>
<option value="Pequena">R$45,00</option>
<option value="Média">R$70,00</option>
<option value="Grande">R$95,00</option>
<option value="Gigante">R$120,00</option>
</datalist>
<p>Quantidade de Pizzas:</p>
<input list="qntpizza" name="qntpizza" required />
<datalist id="qntpizza">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</datalist>
<p>Tamanho do Refrigerante:</p>
<input list="tmhrefri" name="tmhrefri" required />
<datalist id="tmhrefri">
<option value="350ml">R$4,50</option>
<option value="750ml">R$6,30</option>
<option value="1L">R$8,10</option>
<option value="2L">R$9,90</option>
<option value="2,5L">R$11,70</option>
</datalist>
<p>Quantidade de Refrigerante:</p>
<input list="qntrefri" name="qntrefri" required />
<datalist id="qntrefri">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</datalist><br />
<input type="button" name="voltar" value="Voltar" />
<button>Calcular</button>
Can you put the code you made? how are you generating this HTML? you can add information to the HTML or you already get "done" and you can’t change?
– Sergio
Use
datalist
complicates a bit, umselect
would be better because thedatalist
does not have for exampleselectedIndex
and it’s hard to get theinnerHTML
. If you answer my questions upstairs I can help you better.– Sergio