I want to make a form in HTML & JS in client-side. I know how to make a search form that iterates through an array or a object, and the webpage displays A when your search value is B. But how can I add the select element in my function to make my search form more complex? Image I want the ability to either search for four-wheelers or two-wheelers, and the select field should make it possible to only have one criteria at the time.
Heres a brief explanation of a code resembling what I already know, without using the select element as I have no idea on how to
<html>
<form>
<input id="write" type="text">
<select> <option> Four-wheeler </option> <option> Two-wheeler </option> </select>
<input type="submit" id="btn">
</form>
</html>
<script>
var info = [
new Bil("Ford", 1999, "black"),
new Bil("BMW", 1992, "red"),
];
function search() {
var z = String(field.value);
for(var i = 0; i<info.length; i++) {
if(z === info[i].make) {
para.textContent = info[i].year
}
}
}
</script>