1. Imagine you are a manager of three consultants and you want to keep a running
ID: 3802119 • Letter: 1
Question
1. Imagine you are a manager of three consultants and you want to keep a running total of their value. You need a form where you can add brownie points to their running total whne they have done something for points from the running total when they error. Write a web form that has a dropdown list that is pre-loaded with company's three employers names(text field) and ID'S(value field), a textbo wherein you can type in a textbox for putput. Create one variable for each employee.
Write the procedure tht can take the employee chosend in the dropdownlist, and give them more brownie points based on the number typed into the textbox (if you type -5 the employee lose 5 points if you trype employee gains 5 points). After each transaction write the status of each employee's value on seperate textbox, format the ouput nicely.
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 1px solid #555;
outline: none;
background-color: #f1f1f1;
}
input[type=text]:focus, select:focus {
background-color: lightblue;
}
select {
width: 100%;
padding: 16px 20px;
border: none;
border-radius: 4px;
background-color: #f1f1f1;
}
</style>
<script>
var EmpArray=new Array();
var empObj=new Object();
empObj.id="1";
empObj.name="emp1";
empObj.totalPoints=0;
EmpArray.push(empObj);
var empObj1=new Object();
empObj1.id="2";
empObj1.name="emp2";
empObj1.totalPoints=0
EmpArray.push(empObj1);
var empObj2=new Object();
empObj2.id="3";
empObj2.name="emp3";
empObj2.totalPoints=0
EmpArray.push(empObj2);
function onEmpChange(value)
{
for(var i in EmpArray)
{
if(EmpArray[i].name==value)
{
document.getElementById("empid").value=EmpArray[i].id;
document.getElementById("Totalpoints").value=EmpArray[i].totalPoints;
}
}
}
function calPoints()
{
var value= document.getElementById("points").value;
document.getElementById("points").value="";
if(!isNaN(value))
{
var points=parseInt(value);
var totalPoint=parseInt(document.getElementById("Totalpoints").value);
totalPoint=totalPoint+(points);
document.getElementById("Totalpoints").value=totalPoint;
var emid=document.getElementById("empid").value;
for(var i in EmpArray)
{
if(EmpArray[i].id==emid)
{
EmpArray[i].totalPoints=totalPoint;
}
}
}
}
</script>
</head>
<body>
<form>
<label for="empName" >Employee Name:</label>
<select id="empName" name="empName">
<option value="emp1">Employee1</option>
<option value="emp2">Employee2</option>
<option value="emp3">Employee3</option>
</select>
<label for="id">ID</label>
<input type="text" id="empid" name="id" value="">
<label for="points">Points</label>
<input type="text" id="points" name="points" value="">
<label for="output">Output</label>
<input type="text" id="Totalpoints" name="points" value="">
<input type="button" value="Assign Points"></button>
</form>
</body>
</html>
Description:
please find above code, as per your requirement. if any issues then please comments and dont forget to give feedback.
Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.