Select ID help | Sololearn: Learn to code for FREE!

0

Select ID help

https://code.sololearn.com/W9SwkAwl69GE/#html In my code labeled option select I am having trouble with the JavaScript part of things. What I am trying to do is after selecting the car, I would hit submit, to display some information about the car, function myFunction() { var x = document.getElementById("volvo").innerHTML document.getElementById("demo").innerHTML = "This car is cool"; } function myFunction() { var x = document.getElementById("audi").innerHTML document.getElementById("demo").innerHTML = "This car is ok"; } When i change the car from volvo to audi, the message does not change. I hope i explained this okay enough. Thank you,

1/2/2019 6:27:49 PM

Steven Schick

3 Answers

New Answer

+3

function myFunction() { var x = document.getElementById("carClick").value; if(x == "Volvo") { document.getElementById("demo").innerHTML = "This car is meh"; } else if(x == "Audi") { document.getElementById("demo").innerHTML = "This car is cool"; } }

+5

//You need to know first what car is selected by using( if else) that's all https://code.sololearn.com/WVWn1vY3fulC/?ref=app

+1

thank you so much :)