0
How to get value of x in sin(x) through a form ??
3 ответов
+ 5
<input type="number" id="inout">
<input type="button" value="calculate sin(x)" onclick="clicsin();">
function clicsin() {
var o = document.getElementById("inout"); // get the <input> object
var v = o.value; // get the string 'value' attribute of <input>
v = Number(v); // convert it to number to do calculations
// convert it from degrees to radians if needed
v = Math.sin(v); // get the sinus
o.value = v; // update the 'value' attribute of <input>
}
To display output in an non input element, 'value' attribute don't exist, and you may access the 'innerHTML' property instead to update the node ( element ) content rather than an attribute value ^^
+ 3
Unclear question ^^
Do you want get one result for one value of x or a list of result values for many x values?
Do you are meaning 'form' as <form> html element, or as kind of layout display?
+ 1
yeah its like when I enter the value in form such as 90 than it shows the value of Sin 90....similarly for all the values