FeedBack Details
Feedback Details
Get the feedback details from the user and add it to an array. Display the feedback details in the format as shown in the screenshot.
Concept covered: functions, arrays, control structures and loops, String
Problem Specification:
File name should be index.html.
Create an external script file named script.js.
Use h2 tag for the title of Feedback Details.
Display all the feedbacks followed by a new line separator after printing the above title.
Refer Sample screenshot for more specifications.
Include the script file in html page.
The "Add Feedback" button will add the feedback details to an array.
The "View Feedback" button will display all the feedbacks (multiple feedbacks) in the format as shown in the screenshot in the result div.
Include the below functions/methods in the java script file
[Note:Strictly adhere to the specifications given in the screenshot. Use the same id names for all the corresponding fields specified.]
Sample Input/Output:
Screen1:
Screen 2
Screen 2.1
Screen 3
Solution:
var feed=[];
var x=0
function addFeedback(){
//Fill the required logic
var feedback=document.getElementById('feedback').value;
feed.push(feedback);
document.getElementById('feedback').value="";
document.getElementById("result").innerHTML="<h2>Feedback Details</h2><h3>Successfully Added Feedback Details!<h3>";
}
function displayFeedback(){
//Fill the required logic
var txt="";
var count=1;
for (var i =1; i < feed.length+1; i++) {
txt+="Feedback "+i+"<br>"+feed[i-1]+"<br>";
}
document.getElementById('result').innerHTML="<h2>Feedback Details<h2>"+txt;
}