Here is the HTML doc:
Here is External .js file:
//The data gets passed and the calculations get done here no problem, the problem happens is I cant seem to display the results in the HTML file....its like the values dont get returned back?
Code:
<!DOCTYPE html> <html> <head> <title>Testing a webpage</title> <link rel="stylesheet" type="text/css" href="myStyle.css"> <script src="converter.js"></script> </head> <body> <form> //input some data <input type="button" onclick=converter(70,"fahrenheit") value="TRY"> </form> <p>"Result is "</p> <script type="text/javascript" document.write(converter[0])></script> </body> </html>
Code:
function converter(n, from) { var res=[]; if(from == "fahrenheit") { document.write(n); document.write("<br />"); document.write(from); res[0] = ((5/9.0)*(n-32)); res[1] = ((5/9.0)*(n-32)+273.15); document.write("<br />"); //confirm data passed document.write("here is the result in celcius: func converter calculated: ",res[0]); document.write("<br />"); document.write("here is the result in kelvin: func converter calculated: ",res[1]); return res; //?? } }
Comment