I'm building a booking form using WS Form in Wordpress. Because of the several calculations and conditions accuring when selecting the number of people partecipating in the booking, the form is crazy slow and I've been suggested to use Javascript.
Basically for a numeric field labeled "Adults" and a hypothetical value of 3, I have a separate div that says "Adults number: 3", with the number adjusting according to the field value.
Here is what I tried without success
document.addEventListener('DOMContentLoaded', function() {
// Get the text field by its ID
var textField = document.getElementById('wsf-1-field-13');
// Listen for input event on the text field
textField.addEventListener('input', function() {
// Get the current value of the text field
var currentValue = textField.value;
// Update the HTML editor's content
document.getElementById('adult-number-display').textContent = currentValue;
});
});
where wsf-1-field-13 is the field ID. In the div I used
"Adults number <span id="adult-number-display">1</span>"
However the field is never updating. What am I missing here?