I have an existing form using drop down menu with submit button and it works fine.
I would like to add direct links for select categories links or images outside of the form - how can I accomplish this?
My attempt below does not work.
Any suggestions are appreciated!
<form method="post" action="page.php?cat" id="searchcat">
<select name="Categories">
<option selected>Browse...</option>
<option value="j001">Option 1</option>
<option value="j002">Option 2</option>
<option value="j003">3</option>
<option value="j004">4</option>
...
</select>
</form>
<a onclick="SelectItemByValue(document.getElementById('searchcat'), j004);">
Click here to submit option#4
</a>
<script>
function SelectItemByValue(element, value) {
if (value !== undefined && value !== null) {
var length = element.options.length;
for (var i = 0; i < length; i++) {
if (element.options[i].value === value) {
element.selectedIndex = i;
return;
}
}
}
}
</script>