Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The project asks code the toFahrenheit function and toCelsius function that is executed when the user clicks on the second radio button. It should change

The project asks code the toFahrenheit function and toCelsius function that is executed when the user clicks on the second radio button. It should change the text in the labels for the text boxes so that they appear as in the second interface above. It should also call the clearTextBoxes function to clear the text boxes. image text in transcribed

HTML

Temperature Converter

Temperature Converter

Fahrenheit to Celsius Celsius to Fahrenheit

CSS:

body { font-family: Arial, Helvetica, sans-serif; background-color: white; margin: 0 auto; width: 450px; border: 3px solid blue; } h1 { color: blue; margin: 0 0 .5em; } main { padding: 1em 2em; } label { float: left; width: 10em; margin-right: 1em; } input { margin-bottom: .5em; } #convert { width: 10em; }

"use strict"; var $ = function(id) { return document.getElementById(id); }; var convertTemp;

var clearTextBoxes = function() { $("degrees_entered").value = ""; $("degrees_computed").value = ""; };

/* Fahrenheit function executed when user clicks on the second radio button*/ var toFahrenheit = function() { clearTextBoxes() var convertTemp = (f-32) * (5/9); if ( $("toFahrenheit").checked ) { conversion_type = $("to_celsius").value; } if ( $("toCelsius").checked ) { conversion_type = $("to_fahrenheit").value; } return convertTemp;

}

/* Celsius function to execute when user clicks on the first radio button */

var toCelsius = function() { clearTextBoxes(); var convertTemp = (5 (F-32))*9; if ( $("toCelsius").checked ) { conversion_type = $("to_fahrenheit").value; } if ( $("toFahrenheit").checked ) { conversion_type = $("to_celsius").value; } return convertTemp; }

window.onload = function() { $("convert").onclick = convertTemp; $("to_celsius").onclick = toCelsius; $("to_fahrenheit").onclick = toFahrenheit; $("degrees_entered").focus(); };

Temperature Converter Fahrenheit to Celsius Celsius to Fahrenheit Enter F degrees Degrees Celsius Convert

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

Students also viewed these Databases questions