I have 2 dropdown select forms which validate the options the user chooses with a submit button but I'm not sure of the correct way to "add" my desired content to the search results. Ideally, this would be an image with a header and description.
I tried adding an image using .innerHTML which works but this doesn't seem like the right way to go about it.
Can someone point me in the right direction? Perhaps by providing an example.
function Confirm(){
var people = document.getElementById ("people");
var food = document.getElementById ("food");
if ((people.value == "") && (food.value == ""))
{
alert ("option zero"); //test
}
else if ((people.value == "1") &&(food.value == "1"))
{
alert ("option one"); //test
document.getElementById("result1").innerHTML = "<img src='images/tourism.jpg'>";
}
else if ((people.value == "2") && (food.value == "2"))
{
alert ("option two"); //test
// document.getElementById("result1").innerHTML = "supasdasdasd";
}
}
#result1{
height: 400px;
width: 400px;
background-color: red;
}
#result2{
height: 400px;
width: 400px;
background-color: blue;
}
img {
max-width: 100%;
}
<body>
<form>
<select id="people">
<option value=""> Please Select </option>
<option value="1"> one person </option>
<option value="2"> two person </option>
</select>
<select id="food">
<option value=""> Please Select </option>
<option value="1"> apple </option>
<option value="2"> banana </option>
</select>
<input type="button" value="confirm" onclick="Confirm()" />
</form>
<div id="result1">
</div>
<div id="result2">
</div>
</body>