I am trying to make a button change when a certain option from a drop-down is selected.
document.getElementById("region").onchange = function() {
document.getElementById("order-btn").product-code = this.value;
}
<select name="option" id="option" required>
<option value="1234d1">Option 1</option>
<option value="amdk19">Option 2</option>
<option value="akd1sk">Option 3</option>
<option value="19sd91">Option 4</option>
<option value="asjd91">Option 5</option>
<option value="129e8j">Option 6</option>
</select>
<div class="btn-checkout">
<button id="order-btn" type="submit" product-code="">Checkout</button>
</div>
What I need to happen is when an option is chosen from the drop-down, the product code associated with that option is put into the product-code="HERE"
on the button.
For example, If I chose Option 2 on the drop-down, its product code "amdk19"
would then be put into the button like this:
<button id="order-btn" type="sumbit" product-code="amdk19">
I think this can be done with JavaScript, but I could not figure out how.
Thanks