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,
3 Respostas
+ 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 :)