KASA IT Finishing School – Feedback Automation in Javascript

Question:

KASA IT Finishing school is conducting Corporate and initial training program for many companies and colleges.  Feedback is provided by the participants once the training is over.  The organization wants to automate the Feedback received.  Initially they plan to automate the feedback received from College. 

To facilitate this requirement create a Web page “College Training Feedback Form” that has the below fields. 

Note  :  All validations should be based on HTML 5 (Do not use Javascript)          

Label NameComponent  NameDescription
Participant NameparticipantNameTo enter the name of the participant.The name should accept only alphabets and space.The text “Enter your name” should be displayed by default in the text box. When the user starts entering the value, this text should disappear.
College NamecollegeNameTo enter the college name of the participant.
Participant AddressparticipantAddressTo enter the address of the participant. Provide the correct tag and attribute to create a text area with  5 rows and 20 columns.
GendergenderSelect the gender. Provide the correct input type to make this component a radio button.
Email IDemailTo enter the email of the participant.This field should accept a valid email.
Mobile NumbermobileNumberTo enter the mobile number.The mobile number should accept only digits.  It should contain 10 digits and start with 9/8/7.
Trainer’s NametrainerNameTo enter the trainer’s name
Course NamecourseNameTo enter the course name for which the feedback is provided
Course Completion datedateofcompletionTo select the date of completion of the course
Trainer’s FeedbacktrainerFeedbackAn auto-complete feature should be available to the user for the following options.Excellent, Very Good, Good, Average, Below Average(Name of the auto-complete feature should be “feedback”).Fill the tag to implement the autocomplete feature.
Submit Feedbacksubmit 
ClearResetReset Button.  On clicking this button, all fields should be reset.Provide the input type for this component.

Use JavaScript for doing the below calculation:

When the participant enters the valid values and clicks the “Submit Feedback” button the feedback for the trainer has to be displayed based on the below assumptions :

FeedbackFeedback Rate
Excellent5
Very Good4
Good3
Average2
Below Average1

The result is displayed as  “Feedback rating of  trainerName  is feedbackRate / 5.  Given by participant – participantName”   in a div tag   with  id  “result”.  

Note: Use getElementsByName or getElementById function to retrieve the values

Sample Webpage:

Quiz for Exam - KASA IT Finishing School - Feedback Automation
Quiz for Exam – KASA IT Finishing School – Feedback Automation

On providing the values the web page should look as follows :

Quiz for Exam - KASA IT Finishing School - Feedback Automation
Quiz for Exam – KASA IT Finishing School – Feedback Automation

Styles to be applied: (Do not use Inline CSS)

1.       Body color should be “#FFAACC”.

2.       The heading should be done using <h1> tag the text color should be “#770080”, font should be “Courier New”, style should be “italics” and it should be aligned to center of the webpage.

3.       The result should be bold and color of the text should be #770080.

Code:

feedback.html

<!DOCTYPE html>
<html>
    <head>
        <style>
            body
            {
                background-color: #FFAACC;
            }
            h1
            {
                color: #770080;
                font-style:italic;
                font-family: Courier New;
                text-align: center;
            }
            #result
            {
                color: #770080;
                font-weight: bold;
            }
        </style>
    </head>
    <body>
        <h1>College Training Feedback Form</h1>
        <form onsubmit="return rating()">
            Participant Name<input type="text" name="participantName" id="pname" placeholder="Enter your name" patter="[a-zA-Z ]+"><br>
            College Name<input type="text" name="collegeName"><br>
            Participant Address<textarea name="participantAddress" rows="5" cols="20"></textarea><br>
            Gender<input type="radio" name="gender" value="male">Male 
            <input type="radio" name="gender" value="female">Female<br>
            Email ID<input type="email" name="email"><br>
            Mobile Number<input type="text" name="mobileNumber" pattern="[7-9]{1}[0-9]{9}"><br>
            Trainer's Name<input type="text" name="trainerName" id="tname"><br>
            Course Name<input type="text" name="courseName"><br>
            Course Completion date<input type="date" name="dateofcompletion"><br>
            Trainer's Feedback<input type="text" id="fd" name="trainerFeedback" list="feedback" autocomplete="on">
            <datalist id="feedback" autocomplete="on">
                <option>Excellent</option>
                <option>Very Good</option>
                <option>Good</option>
                <option>Average</option>
                <option>Below Average</option>
            </datalist><br>
            <input type="submit" name="submit" value="Submit Feedback">
            <input type="reset" name="Reset" value="Clear">
        </form>
        <div id="result"></div>
        <script>
            function rating()
            {
                var feed=document.getElementById("fd").value;
                var participantName=document.getElementById("pname").value;
                var trainerName=document.getElementById("tname").value;
                var feedbackRate;
                if(feed=="Excellent")
                {
                    feedbackRate=5;
                }
                else if(feed=="Very Good")
                {
                    feedbackRate=4;
                }
                else if(feed=="Good")
                {
                    feedbackRate=3;
                }
                else if(feed=="Average")
                {
                    feedbackRate=2;
                }
                else if(feed=="Below Average")
                {
                    feedbackRate=1;
                }
                document.getElementById("result").innerHTML="Feedback rating of "+trainerName+" is "+feedbackRate+" / 5. Given by participant - "+participantName;
                return false;
            }
        </script>
    </body>
</html>

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *

x