File manager - Edit - /home/autoph/public_html/tasks/Script.tar
Back
optTotal_Auto_compute_function.txt 0000644 00000004072 15025030221 0013535 0 ustar 00 <script> function optTotal() { var a1 = document.querySelector('select[name="optA"]'); var b1 = document.querySelector('select[name="optB"]'); var c1 = document.querySelector('select[name="optC"]'); var d1 = document.querySelector('select[name="optD"]'); if (a1.value && a1.value != "") a1 = parseFloat(a1.value); else a1 = 0; if (b1.value && b1.value != "") b1 = parseFloat(b1.value); else b1 = 0; if (c1.value && c1.value != "") c1 = parseFloat(c1.value); else c1 = 0; if (d1.value && d1.value != "") d1 = parseFloat(d1.value); else d1 = 0; document.getElementById("total").value = parseFloat(a1)+parseFloat(b1)+parseFloat(c1)+parseFloat(d1); } </script> <form id="frm" name="frm" /> <table> <tr> <td> Name: <br /> <input type="text" name="name" value="<?php if(empty($name[0])){$name[0] = array(NULL);}else{echo $name[0];} ?>" readonly onClick="optTotal()" /> <br /> </td> <td> Score 1: <br /> <input type="text" name="optA" value="<?php if(empty($score1[0])){$score1[0] = array(NULL);}else{echo $score1[0];} ?>" onkeypress="return isnumeric(event)" onClick="optTotal()" /> <br /> </td> <td> Score 2: <br /> <input type="text" name="optB" value="<?php if(empty($score2[0])){$score2[0] = array(NULL);}else{echo $score2[0];} ?>" onkeypress="return isnumeric(event)" onClick="optTotal()" /> <br /> </td> <td> Score 3: <br /> <input type="text" name="optC" value="<?php if(empty($score3[0])){$score3[0] = array(NULL);}else{echo $score3[0];} ?>" onkeypress="return isnumeric(event)" onClick="optTotal()" /> <br /> </td> <td> Score 4: <br /> <input type="text" name="optD" value="<?php if(empty($score4[0])){$score4[0] = array(NULL);}else{echo $score4[0];} ?>" onkeypress="return isnumeric(event)" onClick="optTotal()" /> <br /> </td> <td> Total: <br /> <input type="text" name="total" value="<?php if(empty($total[0])){$total[0] = array(NULL);}else{echo $total[0];} ?>" readonly onKeyUp="optTotal()" /> <br /> </td> </form>