I'm a complete beginner, so after several hours of pasting working scripts into my WP setup without any result, I turn to help. I'm desperate and out of time :(
I'm trying to update a form field based on the input of another form field (first is a select menu, second is a regular text-input). It's a Wordpress / Woocommerce installation with the fields generated by a plugin so I can't control the output. The fields only have names (no IDs) and all examples I find use IDs.
Form code
<select class="addon addon-select" name="addon-8-choose-a-player-0">
<option value="">None</option>
<option data-raw-price="200" data-price="200" value="player-1-1">Player 1</option>
<option data-raw-price="200" data-price="200" value="player-2-2">Player 2</option>
<option data-raw-price="200" data-price="200" value="player-3-3">player 2</option>
</select>
<input type="text" class="input-text addon addon-custom" data-raw-price="100" data-price="100" name="addon-8-name-100-1[0]" value="">
jQuery code
jQuery(document).ready(function( $ ) {
function onchange() {
var box1 = $("select[name='addon-8-choose-a-player-0]");
var box2 = $("#addon-8-name-100-1[0]");
box2.val(box1.val());
}
$("select[name='addon-8-choose-a-player-0]").on('change', onchange);
});