0% found this document useful (0 votes)
14 views

Js Assignments

1. Create an array of courses and prompt the user to select a course. Check if the selected course is in the array and display the appropriate message. 2. Create a greet() function that prompts for a username and alerts a welcome message. Call the greet() function. 3. Create a printMessage() function that prompts for a username and alerts a passed message concatenated with the username. Call the function, passing the message. 4. Add an onkeyup event listener to a textarea to call printMessage() on keyup. The function displays the textarea value in a div. 5. Add an onchange event listener to a course select dropdown to call a function on change.

Uploaded by

Real Humanity
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Js Assignments

1. Create an array of courses and prompt the user to select a course. Check if the selected course is in the array and display the appropriate message. 2. Create a greet() function that prompts for a username and alerts a welcome message. Call the greet() function. 3. Create a printMessage() function that prompts for a username and alerts a passed message concatenated with the username. Call the function, passing the message. 4. Add an onkeyup event listener to a textarea to call printMessage() on keyup. The function displays the textarea value in a div. 5. Add an onchange event listener to a course select dropdown to call a function on change.

Uploaded by

Real Humanity
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Javascript basics

create a courses array with values.


Get the username using prompt
Get the choice of the user for courseName using prompt
Iterate through the array
Print Welcome ${username}
Check for the user choice using If
If the user selects the course in the array
Then print
You have selected ${course}
The course fee is 2000

If the user selects the course that is not available


Then print
The selected course is not available

2. create a function greet().


Within function use prompt to get the username. Then call alert to print welcome username
call greet() function

3.create a function printMessage(msg)


Within function use prompt to get the username.
Then call alert to print the message concatinated with username
call printMessage("Have a great day") function

4. create a textarea with id="comments".create a div with id="mydiv" and background color
Add the onkeyup() to the textarea to call the function printMessage()
In the function get the value of the textarea using getElementById() and assign to "comment"
get the div using getElementById and assign to "divElement"
Assign the variable "comment" to the div using innerHTML
I
5. create a dropdown with the list of courses using select with id="courseName"
Add the onchange() to the select tag to call the function showDetails()
In the function get the value of the select tag using getElementById() and assign to "course"
get the div using getElementById and assign to "divElement"
Assign the variable "course" to the div using innerHTML
1.
2.
3.
4. 1. register.html
5. create a form with form fields as
6. name, password, age (number),gender, course name(dropdown with course names),hobby(checkbox
with hobbies),
7. phone number
8.
9. Validation for this form
10. name - between 5 and 15
11. password - alphabets, uppercase, lowercase, specialchar, number between 5 to 15
12. age - 20-80
13. gender - one should be checked
14. cousrename ---select---
15. phone number 10 numbers
16. date of birth not below 1998
17.
18. submit button as register- on submit call register() function-
19. if something is wrong --------alert(please enter password)
20. ------->alert "registered successfully"
21.
22. 2. newregister.html, success.html [Local Storage]
23. In the same form after submit------> success.html
24. validation has to be done
25. on submit call register() function. After validation --------> print the form details(name,age,course) in
success.html
26.
27.3. login.html
28. username
29. email
30.on submit-------> call login() function
31. create an array with usernames =['Rohan','Raju','Ram'].
32. check if the name is in the array. If the name is not available then alert invalid username
33. if the name is in the array. alert Welcome <username>

You might also like