HTML <p> tags not changing in Javascript -


so making project solve triangles based on user input. using chrome dev editor in order make chrome app. having trouble getting code work though. right now, testing see if change paragraph when button clicked. here piece causing me trouble:

function degtorad(num) {   if (num === undefined) { return; }   return math.pi * num / 180; }   function init() {   var text = document.queryselector("#form1");   sidea = text.elements[0].value;   sideb = text.elements[1].value;   sidec = text.elements[2].value;   anglea = degtorad(text.elements[3].value);   angleb = degtorad(text.elements[4].value);   anglec = degtorad(text.elements[5].value);   whatwegot(); }  //determine algorithm go , run function whatwegot() {   if (anglea === undefined && angleb === undefined && anglec === undefined) {     algsss();   } else if (sidec === undefined && angleb === undefined && anglec === undefined) {     algssa();   } else if (sideb === undefined && sidec === undefined) {     if (anglec === undefined) { anglec = math.pi - (anglea + angleb); }     else if (angleb === undefined) { angleb = math.pi - (anglea + angleb); }     else { anglea = math.pi - (angleb + anglec); }     algasa();   } }  function algsss() {   document.getelementbyid('test').innerhtml = 'sss worked'; } 

here index.html

<!doctype html>  <html> <head>   <title>trigcalc</title>   <script type = "text/javascript" src="main.js"></script>   <link rel="stylesheet" href="styles.css"> </head>  <body>   <div id="greeting"></div>   <p id="prompt1">fill sides a, b, c, angles in degrees <strong>(warning: not test amibiguous case)</strong></p>   <form id="form1" action="form_action.asp">     side a:  <input type="number" name="sidea"><br>     side b:  <input type="number" name="sidec"><br>     side c:  <input type="number" name="sidec"><br>     angle a:  <input type="number" name="anglea"><br>     angle b:  <input type="number" name="angleb"><br>     angle c:  <input type="number" name="anglec"><br>     <input type="button" onclick="init()" value="submit"/>   </form>   <p id='test'></p>  </body> </html> 

other things posted in manifest.json file creates chrome app window , gives other properties. better use jquery sort of thing? thanks.

your "logic" of if's , else's not organized,

it not clear want do. html injection < p > work can see here - fiddle

function whatwegot() {      document.getelementbyid('test').innerhtml = 'sss worked';    if (anglea === undefined && angleb === undefined && anglec === undefined)       .... 

the anglea === undefined etc.. should replace anglea !=0 or !(anglea & angleb & anglec >0) -->

fiddle 2

also, chrome nice debugger utility (f12) can use see value of variables.

as jquery - great , recommended tool. little easier did jquery more complicated things jquery saves lot. must know tool.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -