CP221: IP 1
TEST ONE 2024


Question One

Write a program that displays, validates, and processes a form intended for user registration. User registration captures the following details: username, password, gender (Male or Female), marital status (Single or Married), and preferences (Music, football, netball, volleyball). The form should be validated to prevent submission of empty fields.


Question Two

Write the CSS rules that do the following:

a) Round the corners of the button with class=“button” to 2px

b) Add black shadows to the button with type=“button” to 2px

c) Remove an element with id=“element”


Question Three

a) Write a JavaScript function, which receives an array of numbers as an argument and returns the product of the numbers in the array.

b) Use the JavaScript Document Object Model (DOM) to create a paragraph and add it to the HTML document body. The paragraph displays the message “Welcome to programming”.

c) Write a JavaScript function that deletes an HTML element with id=“item” from the document when an HTML button with id=“button” is clicked.

d) Write a JavaScript function that receives two numbers from a user through Browser Object Model (BOM) popups and displays the summation of the numbers through BOM popups.


END OF TEST