I am trying to create a progress bar that increases as a form is being filled out. For example if I had 5 inputs. Each input would need to be filled out to get to 100% My goal is to activate a button once the form reaches 100%.
My thought process was to do a bunch of if blank make it a value of 0 but if not then it gets a value of 10, or some arbitrary number.
Then I would just add up those values to complete the progress bar.
I am not sure how to set up the values so that I can add them up or this is even the right way to go. I am not sure where to go with it. Here is the code:
<form>
One<input id="1" type="name" name="name"><br />
Two<input id="2" type="name" name="name"><br />
Three<input id="3" type="name" name="else"><br />
Four<input id="4" type="name" name="name"><br />
Five<input id="5" type="name" name="name"><br />
</form>
<div id="progressbar"></div>
$(function() {
$( "#progressbar" ).progressbar({
value: 37
});
});
$(function(){
if ( $('#1').val() == '' ){value == 0};
} else {
value == 10; };
if ( $('#2').val() == '' ){value == 0};
} else {
value == 10; };
if ( $('#3').val() == '' ){value == 0};
} else {
value == 10; };
if ( $('#4').val() == '' ){value == 0};
} else {
value == 10; };
if ( $('#5').val() == '' ){value == 0};
} else {
value == 10; };
});
Any help would be greatly appreciated
HTML:
Javascript:
});
HTML:
Javascript: