The essential problem, in addition to small errors and typos, is that your conditionals are never called after the initial load. Thus the progress bar never gets updated.
If you use html like this:
<select id="optionA">
<option value=" " disabled selected>Choose One...</option>
<option value="mike">Mike</option>
...
</select>
<select id="optionB">
<option value=" " disabled selected>Choose One...</option>=
<option value="rob">Rob</option>
...
</select>
<progress id='progressBar' max='100' value='0'></progress>
And JQuery like this:
var doneA = false;
$('#optionA').on('change', function() {
if (!doneA) {
$("#progressBar").attr('value', $("#progressBar").prop('value')+50);
doneA = true;
}
});
var doneB = false;
$('#optionB').on('change', function() {
if (!doneB) {
$("#progressBar").prop('value', $("#progressBar").attr('value')+50);
doneB = true;
}
});
The result should be as you desire. Here's a working JSFiddle to verify: http://jsfiddle.net/wLt4z/2/
Edit 1: If you want to be more clever, you could assign each form option a shared class, like class='formOption'
, and craft a generic bit of JQuery to update the progress bar appropriately. For example:
$('.formOption').data("done", false);
$('.formOption').on('change', function() {
if (!$(this).data("done")) {
$("#progressBar").attr('value', $("#progressBar").prop('value')+100/$('.formOption').length);
$(this).data("done", true);
}
});
Edit 2: Updated to ensure altering a value doesn't increased the completion percentage. In both cases, this is done by means of a simple boolean flag, which in fact supersedes checking the value.