I found a custom select dropdown with button redirect code. It works with one dropdown, but I want to make two dropdown menus. I tried adding var's for select-id2, but script stopped working and nothing happened.
<select id="select-id1">
<option value="" selected="">First category</option>
<option value="http://example.com">Example</option>
</select>
<select id="select-id2">
<option value="" selected="">Second category</option>
<option value="/page">Page</option>
</select>
<button onclick="siteRedirect()">GO</button>
<script>
function siteRedirect() {
var selectbox = document.getElementById("select-id");
var selectedValue = selectbox.options[selectbox.selectedIndex].value;
window.location.href = selectedValue;
}
</script>
First one (select-id1) should have domain example.com, and the second one (select-id2) should add /page on the first one. So the redirection link should be example.com/page.
Is there any way to do with this code?
document.getElementById("select-id");, but your ids areselect-id1andselect-id2