While working on my code, I have a task where I need to make the progress bar move a specific amount when a name is clicked based on the option's value.
<!DOCTYPE html>
<html>
<head>
<title>testinggg</title>
<link rel="stylesheet" type="text/css" href="AuditScriptAssesmentToolTest.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="~/Scripts/jquery-1.12.4.min.js"></script>
</head>
<body>
<select id="selectA">
<option value=" " disabled selected>Choose One...</option>
<option id="option1" value="5">Mike</option>
<option id="option2" value="10">Andrew</option>
<option id="option3" value="15">Michael</option>
<option id="option4" value="20">Danny</option>
<option id="option5" value="25">Cozz</option>
<option id="option6" value="30">Andrew</option>
<option id="option7" value="35">Pete</option>
<option id="option8" value="40">Sean</option>
<option id="option9" value="45">Dom</option>
<option id="option10" value="50">Marc</option>
<option id="option11" value="0">Lou</option>
<option id="option12" value="0">Rob</option>
</select>
<select id="selectB">
<option value=" " disabled selected>Choose One...</option>
<option id="option1" value="5">Mike</option>
<option id="option2" value="10">Andrew</option>
<option id="option3" value="15">Michael</option>
<option id="option4" value="20">Danny</option>
<option id="option5" value="25">Cozz</option>
<option id="option6" value="30">Andrew</option>
<option id="option7" value="35">Pete</option>
<option id="option8" value="40">Sean</option>
<option id="option9" value="45">Dom</option>
<option id="option10" value="50">Marc</option>
<option id="option11" value="0">Lou</option>
<option id="option12" value="0">Rob</option>
</select>
<progress id='progressBar' max='100' value='0'></progress>
<script>
//document.getElementById("selectA").selectedIndex;
var doneA = false;
$('#selectA').on('change', function() {
if (!doneA) {
$("#progressBar").attr('value', $("#progressBar").prop('value')+25);
doneA = true;
}
});
var doneB = false;
$('#selectB').on('change', function() {
if (!doneB) {
$("#progressBar").attr('value', $("#progressBar").prop('value')+25);
doneB = true;
}
});
</script>
</body>
</html>
Currently, the progress moves by 25% whenever a name is clicked (as set). My query is, instead of assigning a fixed value of 25, can I assign it the specific option's value? For instance, Option4 (which is Danny) has a value of 20, so the objective is to do this...
$("#progressBar").attr('value', $("#progressBar").prop('value')+Option4);
instead of:
$("#progressBar").attr('value', $("#progressBar").prop('value')+ 25);