I have this problem where I am supposed to ask for user input and based on that input display an image and audio. This is what I have so far.
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "styles/lab8.css"/>
<script type="text/javascript">
function input() {
do{
var choice = window.prompt("Enter C for Chekov, U for Uhura, or L for Sulu", "Enter Letter");
}
while(choice != 'C' && choice != 'U' && choice != 'L');
function chekov() {
//remove display : none
}
if(choice == "C"){
document.write("chekov()");
}
else if(choice == "L"){
document.getElementById("L");
}
else if(choice == "U"){
document.getElementById("U");
}
}
</script>
</head>
<body id = "body" onload= "input()">
<div id = "paragraph" >
<p>
Star Trek has been a cult phenomenon for decades.
Fans of the franchise are called Trekkies or Trekkers.
The franchise spans a wide range of spin-offs including games, figurines, novels, toys, and comics. Star Trek had a themed attraction in Las Vegas that opened in 1998 and closed in September 2008.
At least two museum exhibits of props travel the world.
The series has its own full-fledged constructed language, Klingon.
Several parodies have been made of Star Trek.
In addition, viewers have produced several fan productions.
Star Trek is noted for its influence on the world outside of science fiction.
It has been cited as an inspiration for several technological inventions, including the cell phone and tablets.
The franchise is also noted for its progressive era civil rights stances.
The original series included one of television's first multiracial casts.
Star Trek references can be found throughout popular culture from movies such as the submarine thriller Crimson Tide to the animated series South Park.
</p>
</div>
</body>
<div class = "display" id = "C">
<img src = "chekov.jpg" id = "image">
<audio controls id ="audio">
<source src = "chekov.mp3" type="audio/mpeg">
</audio>
</div>
<div class = "display" id = "L">
<img src = "sulu.jpg" id = "image">
<audio controls id ="audio">
<source src = "sulu.mp3" type="audio/mpeg">
</audio>
</div>
<div class = "display" id = "U">
<img src = "uhura.bmp" id = "image">
<audio controls id ="audio">
<source src = "uhura.mp3" type="audio/mpeg">
</audio>
</div>
</html>
and this is the external CSS
div.display{width:70%;background-color:#ccffe6;display:none; }
#audio {margin: 5px 5px 5px 5px;}
#paragraph {margin: 5px 5px 5px 5px;border: solid; width : 70%; background-color:#ffcc00;padding:5px;color: #b300b3;}
#body {background-color : #b30000;}
#image {margin: 5px 5px 5px 5px;border: 15px solid #660066}
I only changed the code for option c to test. What I want to do is that when the user inputs C, it will print the function such that the id's class "display" has the "display : none" removed. Is there a way to remove the :display : none" from a class a function, or is there and alternative method. I was considering making it so the function changes the class to another class that is identical without the "display : none", but I feel that is the wrong way to go about this and would prefer not to use it.
This is my first time introduced to javascript and html so I would love suggestion to approach the problem and explanations on why I need to do certain things.