JSFiddle - React, Tailwind, and code Playground
HTML
<form class="search" onsubmit="this.action=document.getElementById('fsearch').value">
<label>Ihre Auswahl: <input size="30" id="fsearch" type="search" list="pages" placeholder="🔍"></label>
<datalist id="pages">
<option value="Kontakt">pub/kontakt.html</option>
<option value="Impressum">pub/kontakt.html#impressum</option>
<option value="Musik: Gitarrenunterricht">pub/musik-gitarrenunterricht-laufental.html</option>
<option value="SelfHtml: Bugreport">https://wiki.selfhtml.org/wiki/Benutzer:Beatovich</option>
<option value="Javascript: Klapper-Logic">klapperlogic.html</option>
<option value="Home">/</option>
</datalist>
<button type="submit" value="suchen">🔍</button>
</form>
<span id="actionInfo"></span>
JavaScript
document.querySelector("form.search").addEventListener("submit", function(event) {
let suchwert = document.getElementById("fsearch").value;
let action = "https://duckduckgo.com"
let options = document.querySelectorAll("#pages option");
for (let i=0; i<options.length; i++) {
if (options[i].value == suchwert) {
action = options[i].textContent;
break;
}
}
// Hier nur Debug-Ausgabe und Submit verhindern
document.getElementById("actionInfo").textContent = action;
event.preventDefault();
});