Question
Index.Html: Midterm - Part B Delivery Please fix the indicated problems and then resubmit your form. Billing Address First name: Last name: Street Address: Gender:
Index.Html:
Delivery
Please fix the indicated problems and then resubmit your form.
script.js:
/*
Filename: script.js
*/
"use strict"
/* removing default values for gender and year select lists */
function removeSelectDefaults()
{
// ADD YOUR CODE IN HERE
}
/* Copying values from billing to shipping fields */
function copyBillingAddress()
{
// ADD YOUR CODE IN HERE
}
/* Validates addresses fieldsets */
function validateAddresses(fieldsetId)
{
// ADD YOUR CODE IN HERE
}
/* Validating form */
function validateForm()
{
validateAddresses("billingAddress");
validateAddresses("shippingAddress");
if(document.getElementsByTagName("form")[0].checkValidity())
{
document.getElementById("errorMessage").style.display = "none";
} else{
document.getElementById("errorMessage").style.display = "block";
}
}
/* Resets the page */
function resetPage()
{
location.reload();
}
/* Adds event listeners */
function createEventListeners()
{
document.getElementById("submitBtn").addEventListener("click", validateForm);
document.getElementById("sameAddr").addEventListener("click", copyBillingAddress);
document.getElementById("resetBtn").addEventListener("click", resetPage);
}
/* Runs initial form configuration functions */
function setUpPage()
{
removeSelectDefaults();
createEventListeners();
}
/* Runs setup function when page finishes loading */
window.addEventListener("load", setUpPage)
The question are:
Requirements:
1. Add to the JavaScript file a function to copy data from one field to another based on the checkbox Same as Billing Address, that indicates the respective fields should have the same value in the Shipping Address as in the Billing Address.
(6 Copyright Audrey Eernier Laroce. Modifed by fulio Vinieius for COMP125 Yidterm
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started