Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="en-us">
- <head>
- <meta charset="utf-8">
- <title>Choose correct shoes</title>
- <script>
- /* Input: Weather
- * Processing: process user input
- * Output: shoes based on selection
- */
- function selectShoes(){
- // Read Weather from the user
- var weather = document.getElementById("weather").value;
- var shoes = document.getElementById("shoes");
- // Process input
- if (weather == "hot"){
- shoes = "sandals";
- } else if(weather == "rain"){
- shoes = "galoshes";
- } else if(weather == "snow"){
- shoes = "boots";
- } else {shoes = "shoes";}
- // Display shoes
- document.getElementById("shoes").innerHTML = "You should choose " + shoes;
- }
- </script>
- </head>
- <body>
- <br>Input weather<input type="text" id="weather" placeholder="#">
- <button type="button" onclick="selectShoes();">Select Shoes</button>
- <div id="shoes"></div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment