I'm trying to make a small form based on simple HTML, CSS and JavaScript (without JQuery).
In one of the parts of this form, I would like any option
selected of a select
to appear in the comma% separated by commas or lines. In addition, the sum of the values of the selected products should appear in the value field.
Until then, I was able to make the values appear, however, I can not seem to make everything appear in the text area. Here's what I've done so far:
function M() {
document.getElementById("produtos").value = document.getElementById("LstMesas").value;
}
function C() {
document.getElementById("produtos").value = document.getElementById("LstCadeiras").value;
}
function calculaValor(formT) {
var custo1 = document.getElementById("LstCadeiras");
var cadeira = custo1.options[custo1.selectedIndex].value;
var custo2 = document.getElementById("LstMesas");
var mesa = custo2.options[custo2.selectedIndex].value;
cadeira = parseFloat(cadeira);
mesa = parseFloat(mesa);
var total = cadeira + mesa;
document.getElementById("valor").value = total;
}
</fieldset>
<fieldset class="fsResEsq">
<legend> Produtos</legend> <br/> Mesas:
<select size="1" id="LstMesas" name="LstMesas" class="entDir" onchange="calculaValor()" , "M()">
<option value="0" selected></option>
<optgroup label="Diretor">
<option value="500.00">Alfamob Sigma - R$500,00</option>
<option value="360.00">Alfa Painel S40M136 - R$360,00</option>
</optgroup>
<optgroup label="Reunião">
<option value="370.00">Alfamob Corp. semi-oval - R$370,00</option>
</optgroup>
</select><br/>
<br/>Cadeiras:
<select size="1" id="LstCadeiras" name="LstCadeiras" class="entDir" onchange="calculaValor()" , "C()">
<option value="0" selected></option>
<optgroup label="Secretária">
<option value="190.00">Veneza 658 Fixa Couro - R$190,00</option>
<option value="300.00">Turim Gir. Couro - R$300,00</option>
<option value="200.00">Matriz Exp. Gir. Tecido - R$200,00</option>
</optgroup>
<optgroup label="Presidente">
<option value="620.00">Firenze 560 Couro - R$620,00</option>
<option value="800.00">Ipanema Prime Couro - R$800,00</option>
</optgroup>
</select><br/>
<textarea readonly type="text" class="lstSel" id="produtos"></textarea><br/>
<br/>Valor total: <input readonly type="text" name="TxtValor" class="shwValor" id="valor" />
<br/><br/>
</fieldset>