JavaScript TEMPERATURE CONVERSION PROGRAM 🌡️

  Рет қаралды 11,815

Bro Code

8 ай бұрын

#JavaScript #project #programming
00:00:00 HTML
00:04:20 CSS
00:10:43 JavaScript
// TEMPERATURE CONVERSION PROGRAM
const textBox = document.getElementById("textBox");
const toFahrenheit = document.getElementById("toFahrenheit");
const toCelsius = document.getElementById("toCelsius");
const result = document.getElementById("result");
let temp;
function convert(){
if(toFahrenheit.checked){
temp = Number(textBox.value);
temp = temp * 9 / 5 + 32;
result.textContent = temp.toFixed(1) + "°F";
}
else if(toCelsius.checked){
temp = Number(textBox.value);
temp = (temp - 32) * (5/9);
result.textContent = temp.toFixed(1) + "°C";
}
else{
result.textContent = "Select a unit";
}
}

Пікірлер: 29
@BroCodez
@BroCodez 9 ай бұрын
// TEMPERATURE CONVERSION PROGRAM const textBox = document.getElementById("textBox"); const toFahrenheit = document.getElementById("toFahrenheit"); const toCelsius = document.getElementById("toCelsius"); const result = document.getElementById("result"); let temp; function convert(){ if(toFahrenheit.checked){ temp = Number(textBox.value); temp = temp * 9 / 5 + 32; result.textContent = temp.toFixed(1) + "°F"; } else if(toCelsius.checked){ temp = Number(textBox.value); temp = (temp - 32) * (5/9); result.textContent = temp.toFixed(1) + "°C"; } else{ result.textContent = "Select a unit"; } } My website Temperature conversion: Celsius ➡ Fahrenheit Fahrenheit ➡ Celsius submit body{ font-family: Arial, sans-serif; background-color: hsl(0, 0%, 95%); } h1{ color: hsl(223, 100%, 64%); } form{ background-color: hsl(0, 0%, 100%); text-align: center; max-width: 350px; margin: auto; padding: 25px; border-radius: 10px; box-shadow: 5px 5px 15px hsla(0, 0%, 0%, 0.3); } #textBox{ width: 50%; text-align: center; font-size: 2em; border: 2px solid hsla(0, 0%, 0%, 0.8); border-radius: 4px; margin-bottom: 15px; } label{ font-size: 1.5em; font-weight: bold; } button{ margin-top: 15px; background-color: hsl(0, 100%, 60%); color: white; font-size: 1.5em; border: none; padding: 10px 15px; border-radius: 5px; cursor: pointer; } button:hover{ background-color: hsl(0, 100%, 50%); } #result{ font-size: 1.75em; font-weight: bold; }
@drufloud5148
@drufloud5148 2 күн бұрын
Hi guys! If this code also does not work for you and you are sure that you did everything as in this video, then simply change the tag to save and check the code again, this method worked for me. I hope I helped you!
@jelapanoo
@jelapanoo 8 ай бұрын
bro code i just wanna thank you for helping me learn how to code. you're a huge W man, best of luck to u
@Donimaps420
@Donimaps420 8 ай бұрын
Ur da best🎉
@hunin27
@hunin27 8 ай бұрын
Nice styling!
@opiirix3302
@opiirix3302 8 ай бұрын
I tried the code out and it’s awesome 👍
@mksk20
@mksk20 2 ай бұрын
You are great Bro
@rajac6640
@rajac6640 8 ай бұрын
New to this channel sir but your explanation i m founding very helpful just at class 10th but want to do ccommerce and python both . LOVE FROM INDIA❤
@FUN_X_GAME
@FUN_X_GAME 7 ай бұрын
Bro i am 14 and i have learnt ur python course and doing this this is soo good and clear even a 12 year old can do it with your explanation Love from Pakistan
@Lightning_boy5236
@Lightning_boy5236 7 ай бұрын
I am 12..
@sportsknowledge92
@sportsknowledge92 5 ай бұрын
Grate
@xpp_0
@xpp_0 8 ай бұрын
What code do you reccommend to start with?
@mr.kachoo8784
@mr.kachoo8784 8 ай бұрын
The numbers u used in temp is math function for temperature ? Right
@Tanjiro__Kamado
@Tanjiro__Kamado 8 ай бұрын
My bro can u make pandas vidoes or ai with python vidoes pls,tysm for ur effort
@ItzChaos220
@ItzChaos220 8 ай бұрын
how tf r u 1 month agon brocode
@user-mk2md9pu5m
@user-mk2md9pu5m 8 ай бұрын
Hi bro can you make django course or not?
@onlyformonthlytest9739
@onlyformonthlytest9739 4 ай бұрын
Actually submit button is in the form element. when I hit submit button it shows the result and quickly disappeared. I came to know that it's because of default refresh of page when form got submitted. how could I prevent this from quick refresh.
@GHosT_deployyy
@GHosT_deployyy 2 ай бұрын
use this: event.preventDefault(); in the function and this in the submit button: Submit
@FreeThinker_
@FreeThinker_ 2 ай бұрын
Its because the form gets submitted fast. Just change the form element to some div class=" " element and it works fine
@shivasai3643
@shivasai3643 8 ай бұрын
w bro code
@louniis
@louniis 8 ай бұрын
Best fk ing teacher in whole world ❤
@ko_GaZEr
@ko_GaZEr 6 ай бұрын
Tried the same thing, but code is not working😢
@spartondon3591
@spartondon3591 6 ай бұрын
Bruh same situation...! Did you got the solution
@futuredoctor7148
@futuredoctor7148 4 ай бұрын
Check the errors
@escalanteteam7498
@escalanteteam7498 3 ай бұрын
@@spartondon3591 did you figure out why it didnt work?
@GHosT_deployyy
@GHosT_deployyy 2 ай бұрын
@@escalanteteam7498 it happens because of the page refresh, use this: event.preventDefault(); in the function, and this in the html Submit
@raphaelsousa2046
@raphaelsousa2046 11 күн бұрын
works fine for me, check the console to see if you type some variable wrong
@4reyalstseaB
@4reyalstseaB 8 ай бұрын
@Bro CodeWhre can i DM you personally i @ need some help with vs code and and Javascript
That's how money comes into our family
00:14
Mamasoboliha
Рет қаралды 12 МЛН
Incredible magic 🤯✨
00:53
America's Got Talent
Рет қаралды 81 МЛН