I am trying to figure out how to pass a variable assigned to a link on one page and then have it prefill a select option in a form on another page.
Source page link: example.com/page?value=2
Page with form:
<select name="select_name" id="id_name" class="select-success">
<option selected="selected" value=""></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
From reading various posts and the code I have to work with not really matching that criteria. I am a bit js illiterate. I cobbled this together on the page with the form:
document.getElementByType(“select").value = location.search.replace('?','');
Not getting any results. The form is being generated in the backend so I cannot add a id/class or anything to the <option>
.