Take this:
var studentArray = [{rollno:'rollno1', fname:'fname1', marks:'marks1', institute:'institute1', percentage: 'percentage1'},{rollno:'rollno2', fname:'fname2', marks:'marks2', institute:'institute2', percentage: 'percentage2'}];
document.getElementById("search").addEventListener('click', function() {
var roll = document.getElementById("roll").value;
var student, info;
for (i = 0; i < studentArray.length; i++) {
student = studentArray[i];
if (student.rollno == roll) {
info = "First Name: " + student.fname + "<br />";
info += "Marks Obtained: " + student.marks + "<br />";
info += "Institute: " + student.institute+ "<br />";
info += "Percentage: " + student.percentage + "<br />";
document.getElementById("stuInfo").innerHTML = info;
return;
}
}
});
<input id="roll" />
<button id="search">Search</button>
<p id="stuInfo"></p>
4
solved Is it Possible ? To check student information by Roll no: using simple webpage in html + javascript