I’m working with the following form. I can’t edit the html. This is built in a landing page builder.
<select id="how_many_players" name="how_many_players">
<option value=""></option>
<option value="1 to 10">1 to 10</option>
<option value="11 to 20">11 to 20</option>
<option value="21 to 30">21 to 30</option>
<option value="31 to 40">31 to 40</option>
<option value="41 to 50">41 to 50</option>
<option value="50+">50+</option>
</select>
<input id="Price" name="Price" type="hidden" class="hidden" value="$0.00">
I’m looking for JS (?) to change the value in the hidden "price" field based on the option dropdown.
Example: option value 1 to 10 = $100
2
Answers
You get the hidden element through its id and then change the value to the selected option’s value like this:
EDIT:
You probably want to put it into a change event listener for the select, so that the value get’s changed, when the select has changed.
Yes you need to use a little javascript for that, here I put some code to do that.
I would recommend to not used formatted values as input values
Split data values with display values, only format values to display them, not in your functions or real value data