๐Ÿ”’ Closed Javascript help

Status
Not open for further replies.

SUNRAI

Eternal Poster
Pwede po bang pa try sa inyo kung gagana nung in upload ko kase yung file sa drv.tw para maging web page hindi sya gumagana black screen lang.



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<title>ArisSongalia</title>

<script>
<!-- Function created and get element id set to grades-->
<!-- If else statement created with the value of grades-->
function displayGrades() { let equivalent; let grades = document.getElementById('grades').value; if (grades >= 97 && grades <= 100) { equivalent = "Superior"; }
else if (grades >= 88 && grades <= 96) { equivalent = "Above Average"; }
else if (grades >= 75 && grades <= 84) { equivalent = "Average"; }
else if (grades >= 70 && grades <= 74) { equivalent = "Conditional Failure"; }

else if (grades <= 69) { equivalent = "Failure"; }
else { equivalent = "Invalid Input"; } document.getElementById("test").innerHTML = equivalent; }
<!-- Any numbers not in the condition will set to be invalid-->
<!-- get element id set to test -->


</script>
<style>




body{
background-image:url("./img/br.jpeg") ;
background-size:cover;
bottom:500px;
padding : 300px;
{





</style>


</head>

<div id="container"

<body>



<input type="text" id="grades">
<!-- Onclick button created to display grades -->


<button onclick ="displayGrades() ">Display Equivalent</button>
<h2 id="test"></h2>
</div>

<!-- the value will display here-->


</body>
</html>
 
gumagana naman
1603349255279.webp
 
kung gusto mo gumawa sarili web for free kuha ka domain sa freenom tas sa byet host

sarili mo din domain yun
 
1. Yung comment mo sa loob ng script dapat ganito // hindi ganito <!-- -->
2. tapos tingnan mo yung sa loob ng style yung body yung closing bracket baliktad naka ganito "{" naka open siya dapat close ganito '"}"
3. Yung div sa baba ng </head> walang closing na > naka open lang dapat <div id="container">

Gagana yan meron lang mga typographical error.

Tapos medyo magulo yung code mo, mas importante yung readability ng code kesa sa lines of code.
This:
JavaScript:
else if (grades >= 88 && grades <= 96) { equivalent = "Above Average"; }
To this:
JavaScript:
else if (grades >= 88 && grades <= 96) {
    equivalent = "Above Average";
}

Tapos walang hierarchy sa code mo. Lagyan mo ng indention.
This:
JavaScript:
body{
background-image:url("./img/br.jpeg") ;
background-size:cover;
bottom:500px;
padding : 300px;
}
To this:
CSS:
body{
    background-image:url("./img/br.jpeg") ;
    background-size:cover;
    bottom:500px;
    padding : 300px;
}
 
Here's the demo
much better diyan mo itest sa jsfiddle para malalaman mo agad result or errors:
You do not have permission to view the full content of this post. Log in or register now.
or
You do not have permission to view the full content of this post. Log in or register now.

HDxCMc6.webp

tips: para malalaman mo error sa js mo.
pwede mong icheck dito sa site: You do not have permission to view the full content of this post. Log in or register now.
see this example. inalis ko yung ibang bracket
dpHoriG.webp
 
On a different topic, there's huge benefits with making your code look tidy and organize. It makes your project easy to read and reason out.
 
Status
Not open for further replies.

About this Thread

  • 8
    Replies
  • 358
    Views
  • 6
    Participants
Last reply from:
pixkit

Online now

Members online
975
Guests online
2,654
Total visitors
3,629

Forum statistics

Threads
2,276,141
Posts
28,967,846
Members
1,231,131
Latest member
Yrrojan
Back
Top