io, ho un codice che sfrutta sempre name, ovviamente cosi non funziona perche name è diverso l'uno da l'altro, ma se metto name="product" funziona benissimo, vorrei che invece di usare name="product" usasse id="product"
codice:<tr> <td>Cuscino</td> <td><input type="checkbox" name="check_cs" id="product" value="100" onclick="p_fioric()"> <textarea rows="2" name="cuscino" cols="50"></textarea><br> <font size="2">Inserire dettagli e scritta per la fascia</font></td> <td></td> <td>Copricassa</td> <td><input type="checkbox" name="check_cp" id="product" value="200" onclick="p_fioric()"> <textarea rows="2" name="copric" cols="50"></textarea><br> <font size="2">Inserire dettagli e scritta per la fascia</font></td> </tr> <tr> <td>Cesti</td> <td><input type="checkbox" name="check_cc" id="product" value="90" onclick="p_fioric()"> <textarea rows="2" name="cesti" cols="50"></textarea><br> <font size="2">Inserire dettagli e scritta per la fascia</font></td> <td></td> <td>Composizioni</td> <td><input type="checkbox" name="check_comp" id="product" value="70" onclick="p_fioric()"> <textarea rows="2" name="composizioni" cols="50"></textarea><br> <font size="2">Inserire dettagli e scritta per la fascia</font></td> </tr> function p_fioric() { var input = document.getElementsByName("product"); var total = 0; for (var i = 0; i < input.length; i++) { if (input[i].checked) { total += parseFloat(input[i].value); } } document.getElementsByName("p_fiori")[0].value = total; }

Rispondi quotando