Я сделал пример для выбора хрома.Вы можете расширить дальше для других браузеров.Документация в источнике.
const selected = document.getElementsByTagName('input')[0];
selected.addEventListener("change", () => {
const browser = selected.value;
/* Create an array with all elements having class = input */
const allFields = [...document.getElementsByClassName("input")];
/* Hide all fields */
allFields.map(field => field.style.display = "none");
/* Show the fields depending on browser selection */
switch (browser.toLowerCase()) {
case "chrome":
/* Title, Organization & Description */
document.getElementById("title").style.display = "block";
document.getElementById("organization").style.display = "block";
document.getElementById("description").style.display = "block";
break;
case "firefox":
break;
default:
/* Any code that should run if no browser matches */
}
});
.input {
margin: 0 0 1rem 0; /* White space at bottom */
}
<label>Choose a browser from this list:
<input list="browsers" name="myBrowser" placeholder="Select" /></label>
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Internet Explorer">
<option value="Opera">
<option value="Safari">
<option value="Microsoft Edge">
</datalist>
<br><br>
<div id="title" class="input">
<label>Title </label><input type="text" name="title">
</div>
<div id="subtitle" class="input">
<label>Sub title </label><input type="text" name="subtitle">
</div>
<div id="developed" class="input">
<label>Developed by </label><input type="text" name="developer">
</div>
<div id="organization" class="input">
<label>Organization </label><input type="text" name="organization">
</div>
<div id="description" class="input">
<label>Description </label><input type="textarea" name="description">
</div>