I have a form element that I change the action of with the following code
HTML:
<form action='#' id='EventsBlockForm'>
<select id='artikler' onchange='getUrl(this)'>
<option disabled selected>-- Velg artikkel</option>
<option value='/?id=198405547&Article=1'>Article 1</option>
</select>
<button type='submit'>Go to article</button>
<form>
JS:
function getUrl(input) {
let form = document.getElementById("EventsBlockForm");
form.action = input.value;
}
The javascript works and it does change the action to the correct value, however when I click the submit button it sends me to /?id=198405547
instead of sending me to /?id=198405547&Article=1
. Is there a way to get the second GET variable in the action. This works fine if I use a a
elemenent instead of the button.