I have a WordPress form with a Radio Button input label and value that I need to dynamically generate depending on the input of a another field.
I have no control over how the form is generated (without digging into the plugin, and time is is very much against me, so I just need a quick solution)
WordPress is generating html as follows
<input type="text" name="vfb-22" id="vfb-4-50-22" value="" class="vfb-text vfb-medium number" />
<label for="vfb-4-50-22" class="vfb-desc">Number * 4.50:></label>
<span>
<input type="radio" name="vfb-28" id="vfb-and-then-28-1" value="4.50" class="vfb-radio inline" />
<label for="vfb-and-then-28-1" class="vfb-choice">4.50</label>
</span>
If someone enters a value into field A(vfb-22). I need jQuery to change the value of the input radio button and the label to A * the current value
I currently get all the relevant figures and update another field (vfb-42) correctly as follows
$('#vfb-monthly-tickets-4-50-each-86').change(function() {
var number=$('input[name=vfb-86]').val();
var multiplier=4.50;
total=number*multiplier;
$('input[name=vfb-42]').val(total);
})
All I’m missing is changing the values of the radio button (vfb-28). I’ve had a few stabs, with no success to either label of value.
Grateful for any thoughts
Admittedly this is just a refactor of your own method, but you could try: