{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-09-10T10:17:24-04:00", "answer_date": "2024-09-10 10:17:24", "is_docs_available": null, "is_excel_available": null, "is_pdf_available": null, "count_file_available": 0, "main_page": "student_question_view", "question_id": "10062243", "url": "\/study-help\/questions\/fix-the-html-so-there-is-no-more-embedded-javascript-10062243", "question_creation_date_js": "2024-09-10T10:17:24-04:00", "question_creation_date": "Sep 10, 2024 10:17 AM", "meta_title": "[Solved] Fix the HTML so there is no more embedded | SolutionInn", "meta_description": "Answer of - Fix the HTML so there is no more embedded Javascript HTML CODE: Calculator My Calculator This web page requires JavaSc | SolutionInn", "meta_keywords": "fix,html,embedded,javascript,code,calculator,web,page,requires,enabled,browser,enter", "question_title_h1": "Fix the HTML so there is no more embedded Javascript HTML CODE: Calculator My Calculator This web page requires JavaScript to be enabled on your", "question_title": "Fix the HTML so there is no more embedded Javascript HTML CODE:", "question_title_for_js_snippet": "Fix the HTML so there is no more embedded Javascript HTML CODE Calculator My Calculator This web page requires JavaScript to be enabled on your browser Please enter a numeric value or use the number buttons below Validate HTML Validate CSS JAVA SCRIPT Global variables var prevCalc 0 var calc The following function displays a number in the textfield when a number is clicked Note that it keeps concatenating numbers which are clicked function showNum(value) document frmCalc txtNumber value value The following function decreases the value of displayed number by 1 isNaN method checks whether the value passed to the method is a number or not function decrement() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) num document frmCalc txtNumber value num The following function increases the value of displayed number by 1 isNaN method checks whether the value passed to the method is a number or not function increment() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) num document frmCalc txtNumber value num The following function is called when sqrt button is clicked Note that it also changes the values of the global variables function sqrt() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) var sqrtvalue Math sqrt(num) document frmCalc txtNumber value sqrtvalue The following function is called when floor button is clicked Note that it also changes the values of the global variables function floor() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) var floorvalue Math floor(num) document frmCalc txtNumber value floorvalue The following function is called when round button is clicked Note that it also changes the values of the global variables function round() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) var roundvalue Math round(num) document frmCalc txtNumber value roundvalue The following function is called when square button is clicked Note that it also changes the values of the global variables function square() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) var powvalue Math pow(num, 2) document frmCalc txtNumber value powvalue The following function is called when Add button is clicked Note that it also changes the values of the global variables function add() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) prevCalc num document frmCalc txtNumber value calc Add The following function is called when Subtract button is clicked Note that it also changes the values of the global variables function subtract() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) prevCalc num document frmCalc txtNumber value calc Subtract The following function is called when Multiply button is clicked Note that it also changes the values of the global variables function multiply() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) prevCalc num document frmCalc txtNumber value calc Multiply The following function is called when Divide button is clicked Note that it also changes the values of the global variables function divide() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) prevCalc num document frmCalc txtNumber value calc Divide The following function is called when Power button is clicked Note that it also changes the values of the global variables function power() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) prevCalc num document frmCalc txtNumber value calc Power The following function is called when Calculate button is clicked Note that this function is dependent on the value of global variable function calculate() var num parseFloat(document frmCalc txtNumber value) if ( (isNaN(num))) var total 0 if (calc Add ) total prevCalc num document frmCalc txtNumber value total else if (calc Subtract ) total prevCalc num document frmCalc txtNumber value total else if (calc Multiply ) total prevCalc num document frmCalc txtNumber value total else if (calc Divide ) total prevCalc num document frmCalc txtNumber value total else if (calc Power ) total Math pow(prevCalc, num) document frmCalc txtNumber value total function clear() document frmCalc txtNumber value prevCalc 0 calc ", "question_description": "

Fix the HTML so there is no more embedded Javascript<\/p>

<\/p>

HTML CODE:<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

Calculator<\/title><\/p> <p> <!-- Meta tag for keywords --><\/p> <p> <meta name=\"keywords\" content=\"Calculator\" ><\/p> <p> <!-- Meta tag for description --><\/p> <p> <meta name=\"description\" content=\"ITIS 2300 Lab 8\" ><\/p> <p><!-- Meta tag for character encoding --><\/p> <p> <meta charset=\"UTF-8\"><\/p> <p> <!--External Stylesheet --><\/p> <p> <link rel=\"stylesheet\" type=\"text\/css\" href=\"Lab8.css\"><\/p> <p><!-- JavaScript function declarations --><\/p> <p> <script src=\"Lab8_Solution.js\"><\/script><\/p> <p> <\/p> <p><\/head><\/p> <p> <\/p> <p><body><\/p> <p> <header><\/p> <p><h1>My Calculator<\/h1><\/p> <p><!-- For people who don't have JavaScript enabled--><\/p> <p><noscript>This web page requires JavaScript to be enabled on your browser.<\/noscript><\/p> <p><\/header><\/p> <p> <\/p> <p> <\/p> <p><main id=\"calc\"><\/p> <p> <\/p> <p><!-- form for user input that represents a calculator --><\/p> <p><form name=\"frmCalc\" id=\"frmCalc\"><\/p> <p><p>Please enter a numeric value or use the number buttons below.<\/p><\/p> <p><!-- Text Box to enter a numeric value --><\/p> <p><input type=\"text\" name=\"txtNumber\" value=\"\" size=\"20\" \/><br \/><br\/><\/p> <p><!-- Number buttons --><\/p> <p><input type=\"button\" value=\"1\" name=\"btn1\" onclick=\"showNum(1)\" \/><\/p> <p><input type=\"button\" value=\"2\" name=\"btn2\" onclick=\"showNum(2)\" \/><\/p> <p><input type=\"button\" value=\"3\" name=\"btn3\" onclick=\"showNum(3)\" \/><\/p> <p><!-- ADD: Sets up operation to add current number to next number entered --><\/p> <p><input type=\"button\" value=\"+\" name=\"btnPlus\" onclick=\"add()\" \/><br\/><\/p> <p><!-- Number buttons --><\/p> <p><input type=\"button\" value=\"4\" name=\"btn4\" onclick=\"showNum(4)\" \/><\/p> <p><input type=\"button\" value=\"5\" name=\"btn5\" onclick=\"showNum(5)\" \/><\/p> <p><input type=\"button\" value=\"6\" name=\"btn6\" onclick=\"showNum(6)\" \/><\/p> <p><!-- *** Subtract *** --><\/p> <p><input type=\"button\" value=\"-\" name=\"btnMinus\" onclick=\"subtract()\" \/><br\/><\/p> <p><!-- Number buttons --><\/p> <p><input type=\"button\" value=\"7\" name=\"btn7\" onclick=\"showNum(7)\" \/><\/p> <p><input type=\"button\" value=\"8\" name=\"btn8\" onclick=\"showNum(8)\" \/><\/p> <p><input type=\"button\" value=\"9\" name=\"btn9\" onclick=\"showNum(9)\" \/><\/p> <p><!-- *** Multiply *** --><\/p> <p><input type=\"button\" value=\"*\" name=\"btnTimes\" onclick=\"multiply()\" \/><br\/><\/p> <p><!-- Number buttons --><\/p> <p><input type=\"button\" value=\"0\" name=\"btn0\" onclick=\"showNum(0)\" \/><\/p> <p> <\/p> <p><!-- *** Power Takes two values n^y *** --><\/p> <p><input type=\"button\" value=\"^\" name=\"btnPow\" onclick=\"power()\"\/><\/p> <p><!-- *** Power2 *** Takes one value n^2--><\/p> <p><input type=\"button\" value=\"^2\" name=\"btnPow2\" onclick=\"square()\"\/><\/p> <p><!-- *** Divide *** --><\/p> <p><input type=\"button\" value=\"\/\" name=\"btnDivide\" onclick=\"divide()\"\/><\/p> <p> <\/p> <p><br \/><\/p> <p><!-- Decrements value currently displayed --><\/p> <p><input type=\"button\" value=\"--\" name=\"btnDecrement\" onclick=\"decrement()\" \/><\/p> <p><!-- *** Increment *** --><\/p> <p><input type=\"button\" value=\"++\" name=\"btnIncrement\" onclick=\"increment()\"\/><\/p> <p><!-- *** Square Root *** --><\/p> <p><input type=\"button\" value=\"sqrt()\" name=\"btnSqrt\" onclick=\"sqrt()\"\/><br \/><\/p> <p> <\/p> <p><!-- Calculates the floor of the current number being displayed --><\/p> <p><input type=\"button\" value=\"Floor\" name=\"btnFloor\" onclick=\"floor()\" \/> <\/p> <p> <\/p> <p><!-- *** Round *** --><\/p> <p><input type=\"button\" value=\"Round\" name=\"btnRound\" onclick=\"round()\"\/><\/p> <p><!-- *** Decimal *** --><\/p> <p><input type=\"button\" value=\".\" name=\"btnDecimal\" onclick=\"showNum('.')\" \/><\/p> <p><br\/><br\/><\/p> <p> <\/p> <p><input type=\"reset\" name=\"btnReset\" value=\"Clear\" onclick=\"clear()\" \/><\/p> <p><input type=\"button\" name=\"btnCalc\" value=\"Calculate\" onclick=\"calculate()\" \/><\/p> <p><\/form><\/p> <p> <\/main><\/p> <p><footer id=\"Validation\"><\/p> <p><br\/><\/p> <p>Validate HTML <\/p> <p>Validate CSS<\/p> <p><\/footer><\/p> <p> <\/p> <p><\/body><\/p> <p><\/html><\/p> <p>____________________________________________________<\/p> <p>JAVA SCRIPT<\/p> <p>_______________________________________________________<\/p> <p>\/Global variables<\/p> <p>var prevCalc = 0;<\/p> <p>var calc = \"\";<\/p> <p> <\/p> <p> <\/p> <p> <\/p> <p> <\/p> <p>\/\/The following function displays a number in the textfield when a number is clicked.<\/p> <p>\/\/Note that it keeps concatenating numbers which are clicked.<\/p> <p>function showNum(value) {<\/p> <p> document.frmCalc.txtNumber.value += value;<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function decreases the value of displayed number by 1.<\/p> <p>\/\/isNaN method checks whether the value passed to the method is a number or not.<\/p> <p>function decrement() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> num--;<\/p> <p> document.frmCalc.txtNumber.value = num;<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function increases the value of displayed number by 1.<\/p> <p>\/\/isNaN method checks whether the value passed to the method is a number or not.<\/p> <p>function increment() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> num++;<\/p> <p> document.frmCalc.txtNumber.value = num;<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"sqrt\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function sqrt() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> var sqrtvalue = Math.sqrt(num);<\/p> <p> document.frmCalc.txtNumber.value = sqrtvalue;<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"floor\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function floor() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> var floorvalue = Math.floor(num);<\/p> <p> document.frmCalc.txtNumber.value = floorvalue;<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"round\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function round() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> var roundvalue = Math.round(num);<\/p> <p> document.frmCalc.txtNumber.value = roundvalue;<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"square\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function square() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> var powvalue = Math.pow(num, 2);<\/p> <p> document.frmCalc.txtNumber.value = powvalue;<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"Add\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function add() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> prevCalc = num;<\/p> <p> document.frmCalc.txtNumber.value = \"\";<\/p> <p> calc = \"Add\";<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"Subtract\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function subtract() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> prevCalc = num;<\/p> <p> document.frmCalc.txtNumber.value = \"\";<\/p> <p> calc = \"Subtract\";<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"Multiply\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function multiply() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> prevCalc = num;<\/p> <p> document.frmCalc.txtNumber.value = \"\";<\/p> <p> calc = \"Multiply\";<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"Divide\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function divide() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> prevCalc = num;<\/p> <p> document.frmCalc.txtNumber.value = \"\";<\/p> <p> calc = \"Divide\";<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"Power\" button is clicked.<\/p> <p>\/\/Note that it also changes the values of the global variables.<\/p> <p>function power() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> prevCalc = num;<\/p> <p> document.frmCalc.txtNumber.value = \"\";<\/p> <p> calc = \"Power\";<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>\/\/The following function is called when \"Calculate\" button is clicked.<\/p> <p>\/\/Note that this function is dependent on the value of global variable.<\/p> <p>function calculate() {<\/p> <p> var num = parseFloat(document.frmCalc.txtNumber.value);<\/p> <p> if (!(isNaN(num))) {<\/p> <p> var total = 0;<\/p> <p> <\/p> <p> if (calc == \"Add\"){<\/p> <p> total = prevCalc + num;<\/p> <p> document.frmCalc.txtNumber.value = total;<\/p> <p> } else if (calc == \"Subtract\") {<\/p> <p> total = prevCalc - num;<\/p> <p> document.frmCalc.txtNumber.value = total;<\/p> <p> } else if (calc == \"Multiply\") {<\/p> <p> total = prevCalc * num;<\/p> <p> document.frmCalc.txtNumber.value = total;<\/p> <p> } else if (calc == \"Divide\") {<\/p> <p> total = prevCalc \/ num;<\/p> <p> document.frmCalc.txtNumber.value = total;<\/p> <p> } else if (calc == \"Power\") {<\/p> <p> total = Math.pow(prevCalc, num);<\/p> <p> document.frmCalc.txtNumber.value = total;<\/p> <p> }<\/p> <p> }<\/p> <p>}<\/p> <p> <\/p> <p>function clear() {<\/p> <p> document.frmCalc.txtNumber.value = \"\";<\/p> <p> prevCalc = 0;<\/p> <p> calc = \"\";<\/p> <p>}<\/p>", "transcribed_text": "", "related_book": { "title": null, "isbn": null, "edition": null, "authors": null, "cover_image": null, "uri": null, "see_more_uri": "" }, "free_related_book": { "isbn": "", "uri": "", "name": "", "edition": "" }, "question_posted": "2024-09-10 10:17:24", "see_more_questions_link": "\/study-help\/questions\/computer-science-operating-system-2022-August-09", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/introduction-to-probability-statistics\/10118-arranging-objects-the-following-data-are-the-response-times-1986529", "description": "10.118 Arranging Objects The following data are the response times in seconds for n = 25 first graders to arrange three objects by size. Find a 95% confidence interval for the average re- sponse time...", "stars": 0 }, { "url": "\/study-help\/questions\/case-26-pasta-etc-family-restaurants-you-are-a-member-353775", "description": "You are a member of an independent consulting firm that specializes in serving the restaurant industry. Unlike many consulting firms that are extensions of audit firms, your firm has serious and in...", "stars": 3 }, { "url": "\/study-help\/questions\/q1-in-python-languages-implement-a-stack-using-queue-such-9987551", "description": "Q1) in python languages Implement a stack using queue. Such that all operations of the stack are Implemented in a correct way. Stack operations: a) Push b) Pop c) Isempty d) Is full e) Print stack f)...", "stars": 3 }, { "url": "\/study-help\/questions\/prepared-from-a-situation-suggested-by-professor-john-w-2433713", "description": "( Prepared from a situation suggested by Professor John W . Hardy. ) Lone Star Meat Packers is a major processor of beef and other meat products. The company has a large amount of T - bone steak on...", "stars": 3 }, { "url": "\/study-help\/questions\/propose-three-upgrading-solutions-for-the-hq-minimum-five-floors-999759", "description": "Propose THREE upgrading solutions for the HQ (minimum FIVE floors). Your proposal MUST be based on upgrading the existing HQ network infrastructure you have discussed above. Provide detail...", "stars": 3 }, { "url": "\/study-help\/questions\/how-could-you-use-social-media-such-as-the-companys-999763", "description": "How could you use social media such as the company's Facebook page, its official blog, and the blogs and pages of individual departments and employees to collect information that would potentially be...", "stars": 3 }, { "url": "\/study-help\/questions\/as-one-of-the-botho-students-who-has-done-1000144", "description": ". As one of the Botho students, who has done standard costing as one of the topics in the Cost Accounting module, you have been invited to come and table a discussion on possible causes of variances...", "stars": 3 }, { "url": "\/study-help\/questions\/students-must-both-address-the-discussion-forum-issues-as-well-999749", "description": "Students must both address the Discussion Forum issue(s), as well as comment on the posts of a minimum of two of their classmates to adequately complete the assignment. Students striving for a...", "stars": 3 }, { "url": "\/study-help\/questions\/1-abc-inc-is-a-big-manufacturing-organization-based-in-1011875", "description": "1) ABC Inc. is a big manufacturing organization based in the USA. It has multiple branches in different states in the USA. All servers and workstations of each branch are connected through LANs, and...", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/question-5-choose-true-or-false-as-applicable-for-each-10062242", "next": "\/study-help\/questions\/same-question-but-now-ab-etc-stand-for-arbitrary-sets-10062244" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "Fix the HTML so there is no more embedded Javascript HTML CODE:", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/fix-the-html-so-there-is-no-more-embedded-javascript-10062243" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } }