javascript - Form help: input - output for math function -
i need help. need javascript code following function:
n = 1 + (log(5156559813)/log(x))/log(3)
where n output , x input box.
how make input box x? use document.getelementbyid("x").innerhtml = 1 + (math.log(5156559813) / math.log(x)) / math.log(3)
?
i've searched wrong thing keeps coming every time.
here's code:
<form class="uk-form"> <fieldset data-uk-margin> <input type="text" placeholder="people in group" id="x"> <button class="uk-button uk-button-primary">go!</button> <p id="number"></p> </fieldset> <script type="text/javascript"> function n(x){ return document.getelementbyid("number").innerhtml = 1 + (9.7123600597) / math.log(x)) / 0.4771212547; document.getelementbyid('x').addeventlistener('change', function () { document.getelementbyid('n').innerhtml = n(this.value); }, false); } </script> </form>
whenever hit button, page refreshes , @ beginning again.
thank much!
use math.log()
base e, math.log10()
base 10 , math.log2()
base 2. note log10
, log2
not supported on internet explorer
Comments
Post a Comment