What am I doing wrong?
The program works until I try to add the validation.
BTW there are more functions beside m_to_k
Code:function validator() var MINNUM = <1; var MAXNUM = >1000000; //Validate the inputted meters while((isNaN(meters)) || (meters < MINNUM) || (meters > MAXNUM)) { alert("Invalid digit entered. Must be between 1 & 1000000."); return result; }; var report = function(meters,kilometers) { document.getElementById("result").innerHTML = //"result" gets sent to the HTML page where it is being asked for meters + " meters are equal to " + kilometers + " kilometers"; //is just the text that will show up on the monitor. meters + is what the user typed in. The space after the quotations will insert what was typed in by the user then the text shows up (meters are equal to). + kilometers + inserts the caculation below. The space after the quotations will insert what was caculated. Then the text shows up (kilometers). }; document.getElementById("m_to_k").onclick = function() // after the user types in the digits the user will click on the button of choice which will preform the caculation below. { var meters = document.getElementById("distance").value; //meters will be equal to what the user typed in and be sent to report var kilometers = (meters *.001); //kilometers will be equal to the caculation in parenthises and will send it to report report(meters, kilometers); //this report has the information of the digits that were entered (meters) plus the caculation (kilometers) that will be grabbed by the HTL page to be displayed. };


Reply With Quote
Bookmarks