I have an input field and a progress bar that needs to be updated based on the input.
The task is to input a number (%) and then display that value in the progress bar upon clicking the "Apply" button (btn-primary).
Below is the HTML code provided:
<div class="form-group">
<label for="number">Enter a Number!</label>
<input type="text" class="form-control" id="number" min="0" max="100" required>
</div>
<button type="button" class="btn btn-primary">Apply</button>
<div class="progress-wrap">
<div class="progress-message">Your form is filled at <span class="output">___</span> %</div>
<progress max="100" value="0" class="progress"></progress>
</div>
An attempt was made to write a script, but it does not function properly.
var val = document.querySelector('.form-controll').value;
var btn = document.querySelector('.btn-primary');
var progress = document.querySelector('.progress');
btn.addEventListener('click, displayData');
function displayData() {
progress.attr('value', val);
progress.style.background = 'green';
}
For reference, here is the link to view the codepen: https://codepen.io/ksena19/pen/QVRNep