Right now I'm coding a site for my sis. She will teach art to her classmates tomorrow. She has found some step by step drawings. She would give her classmates diferrent words, then they'll open the site. In the site there will be an "input" question, there they'll type their codes. If they type "cat", they'll have cat tutorial, if they type "turtle", they'll have turtle tutorial.
The question is how to make different answers open different pages?
I don't understand JS yet.
CodePudding user response:
Look what you are asking for is not something you can do perfectly from one day to the other. It takes time to do something good, even as a developer. In your case is even more complicated.
Here I coded something that you can upgrade to accomplish your goal. So mainly there are a bunch of conditions that will select a url
of an image and then it will be displayed on the website depending on the input. Try it by inputting: cat, car or tomato
let input = document.getElementById('answer')
let img = document.getElementById('img')
let n = null
function showImage(){
if(input.value === 'cat') n = 0
else if(input.value === 'car') n = 1
else if(input.value === 'tomato') n = 2
img.src = images[n]
}
let images = [
'https://picsum.photos/200/300',
'https://picsum.photos/220/300',
'https://picsum.photos/230/300'
]
<h3>Some question here (?)</h3>
<label>Answer: </label><input type="text" id="answer" name="fname">
<button onclick='showImage()'>submit</button>
<p>
<img id='img' src=''/>