We use a select field and need the option value inside a url and need to replace a part of the current url. Because some part of the url is dynamic with a formkey, we need to remove everything form the "/product" part. How can we achieve this?
My my current code does not work, because it removes everything and I want to keep the url and only replace everything from the /product part.
HTML:
<select class="id" id="storage">
<option value="210234">option 1</option>
<option value="210345">option 2</option>
<option value="210678">option 3</option>
</select>
<form action="https://example.com/add/uenc/Y3Jvbmlz/product/210145/">
</form>
Current jQuery:
$(document).ready(function(){
$("select.id").change(function(){
var selectedid = $(".id option:selected").val();
$("form").attr("action","/product/"+selectedid);
});
});