I just want to get the square root of total2 .. but it won't appear in the selected box .. here is the javascript codes. i'll comment the html codes.
function myFunction() { var q1 = document.getElementById("qinput1").value; var q2 = document.getElementById("qinput2").value; var q3 = document.getElementById("qinput3").value; var total = parseInt(q1) + parseInt(q2) + parseInt(q3); document.getElementById("ainput3").value=total; var a1 = document.getElementById("ainput1").value; var a2 = document.getElementById("ainput2").value; //from the total we got, lets assign it a variable for further calculation var a3 = document.getElementById("ainput3").value=total; var total2 = parseInt(a1)*parseInt(a2)/ parseInt(a3); document.getElementById("ansA").value = total2; var total3 = math.sqrt(parseInt(total2)); document.getElementById("sqaureD").value = total3; } function myShapes() { document.getElementById('squareA').style.display = document.getElementById('shapes').value == 'Square' ? 'block' : 'none' }
<form action="" id="fcalculation"> <fieldset> <legend>Calculation of qu</legend> <label><i>Ultimate bearing capacity</i> <b>(qu) = </b></label> <input id="qinput1" type="text" placeholder="c'NcFcsFcdFci"/> + <input id="qinput2" type="text" placeholder="qNqFqsFqdFqi"/> + <input id="qinput3" type="text" placeholder="½βγNFγsFγdFγi"/> </fieldset> </form>
it seems that the calculation part at the very end is not working. sorry its my first time to code.
Classname is Math
not math
Try replacing
var total3 = math.sqrt(parseInt(total2,10));
with
var total3 = Math.sqrt(parseInt(total2,10));
Also, looking at your markup, there are no fields with id ainput1
, ainput2
and ainput3
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.