Select ID help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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,

2nd Jan 2019, 6:27 PM
Steven Schick
Steven Schick - avatar
3 Answers
+ 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"; } }
2nd Jan 2019, 7:48 PM
Anna
Anna - avatar
+ 5
//You need to know first what car is selected by using( if else) that's all https://code.sololearn.com/WVWn1vY3fulC/?ref=app
2nd Jan 2019, 7:59 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
thank you so much :)
2nd Jan 2019, 9:40 PM
Steven Schick
Steven Schick - avatar