Question

In the previous assessment, you used a static set of named variables to store the data...

In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will prompt the user to enter in the number of volunteers, event date, organization name, and host name. Using the number of volunteers entered (5–10), the script should loop through to ask the user to enter the recipient name and store it in an array. Once the user has entered all of the names and pressed submit, the page should display each of the invitations one after another at the bottom of the page.

Directions

Use the invitation.html file that you submitted in your previous assessment to add functionality to your form. This new functionality should allow the user to enter in the number of volunteers, whereupon the form will display the corresponding number of input fields for the user to enter information for each volunteer. Once the form is submitted, the data should be stored in an array to be looped through to create separate invitations for each volunteer on a new page.

Make sure to do the following:

  • Add an input field that allows the user to input the number of volunteers as a numeric value.
  • Once the number of volunteers has been entered (by pressing the enter key while the cursor is in the input field), use JavaScript to display the volunteer input fields based upon the number of volunteers entered.
  • Write JavaScript that stores the form into an array of records once the form is submitted.
  • Write JavaScript to Loop through the array of records and then display the invitation message for each volunteer. (Unlike a simple array that contains a single variable for each index, an array of records allows us to store related data fields for each index in the array. If we were going to store this in simple arrays, we would need a separate array for each data field.)
  • Once completed, view your pages in each of your two selected Web browsers to see if the content renders appropriately and consistently within each. Next, verify that your code is error-free using the appropriate browser-specific development tool found in the Resources. Take a screen capture of each of your validation results and save it for submission.

THis is what i have now but this is not correct

HTML

<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />

<title>Invitation Page</title>

<link rel="stylesheet" type="text/css" href="css/main.css" />

</head>

<body>

<header>

<div class="top">

<a class="logo" href="index.html">CapellaVolunteers

<span class="dotcom">.org</span>

</a>

</div>

<nav>

<ul class="topnav">

<li>

<a href="index.html">Home</a>

</li>

<li>

<a href="invitation.html" class="active">Invitation</a>

</li>

<li>

<a href="gallery.html">Gallery</a>

</li>

<li>

<a href="registration.html">Registration</a>

</li>

</ul>

</nav>

</header>

<form>

<input type="number" name="numberOfGuests" placeholder="Enter your Number of Guests" />

<button type="button" value="Submit" onclick="writeDataToSection();">Submit </button>

</form>

<section id="pageForm"><h2>Complete All Fields</h2>

</section>

<article id="placeholderContent"><h3>_</h3>

Hello

<span id="recipientName">recipientName</span>!

<br/>

<br/> You have been invited to volunteer for an event held by

<span id="organizationName">organizationName</span> on

<span id="eventDate">eventDate</span>. Please come to the following website:

<span id="websiteURL">websiteURL</span> to sign up as a volunteer.

<br/>

<br/> Thanks!

<br/>

<br/>

<span id="hostName">hostName</span>

</article>
<script src="js/in.js"></script>

<footer>This events site is for IT-FP3215 tasks.

</footer>

</body>

</html>

JavaScript

function writeDataToSection(e){

var number=document.getElementsByName("numberOfGuests")[0].value;

for(let i=0;i<number;i++){

document.getElementById("pageForm").innerHTML +="<form onsubmit=\"return readData()\"><label for=\"recipientName\">Recipient name:</label><input type=\"text\" name=\"recipientName\" placeholder=\"Enter your Recipient Name\" /><label for=\"organizationName\">Organization name:</label><input type=\"text\" name=\"organizationName\" placeholder=\"Enter your Organization Name\" /><label for=\"eventDate\">Event Date:</label><input type=\"text\" name=\"eventDate\" placeholder=\"Enter your Event Date\" /><label for=\"websiteURL\">URL:</label><input type=\"text\" name=\"websiteURL\" placeholder=\"Enter your Website URL\" /><label for=\"hostName\">Host name:</label><input type=\"text\" name=\"hostName\" placeholder=\"Host Name\" /><input type=\"submit\" value=\"Submit\"></form>";

}

}

function readData() {

var recipientName = document.getElementsByName("recipientName")[0].value;

var organizationName = document.getElementsByName("organizationName")[0].value;

var eventDate = document.getElementsByName("eventDate")[0].value;

var websiteURL = document.getElementsByName("websiteURL")[0].value;

var hostName = document.getElementsByName("hostName")[0].value;

if (

recipientName.trim() == "" ||

organizationName.trim() == "" ||

eventDate.trim() == "" ||

websiteURL.trim() == "" ||

hostName.trim() == ""

) {

alert("Please fill the data.");

} else {

// set all value to display content

document.getElementById("recipientName").innerText = recipientName;

document.getElementById("organizationName").innerText = organizationName;

document.getElementById("eventDate").innerText = eventDate;

document.getElementById("websiteURL").innerText = websiteURL;

document.getElementById("hostName").innerText = hostName;

}

return false; // making browser not to refresh

}

Homework Answers

Answer #1

Was this answer helpful?


<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Invitation Page</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script>
// Global data
var invitations = [];
var numberOfVolunteers = null;
var organizationName = null;
var eventDate = null;
var hostName = null;
function processForm() {
// Read number of volunteers, event date, organization name, and host name
numberOfVolunteers = parseInt(document.getElementsByName("numberOfVolunteers")[0].value);
organizationName = document.getElementsByName("organizationName")[0].value;
eventDate = document.getElementsByName("eventDate")[0].value;
hostName = document.getElementsByName("hostName")[0].value;
createForm();
return false;
}
// Based upon number of volunteers, loop to ask recipient name
function createForm() {
let htmlForm = `<form onsubmit="return readData()">`;
for (let i = 0; i < numberOfVolunteers; i++) {
htmlForm += `<label for="recipientName${i}">Recipient ${i + 1} name:</label>
<input type="text" name="recipientName${i}" placeholder="Enter your Recipient ${i + 1} Name" /><br/>`;
}
htmlForm += `<input type="submit" value="Submit"><br/><br/></form>`;
document.getElementById("pageForm").innerHTML = htmlForm;
}
function readData() {
// Reset invitation array
invitations = [];
// read input data
for (let i = 0; i < numberOfVolunteers; i++) {
const recipientName = document.getElementsByName(`recipientName${i}`)[0].value;
// validating the input data (trim is user truncate the whitespaces)
if (recipientName.trim() == "") {
alert(`Please fill the data for recipient ${i + 1}.`);
return false;
}
// Add to invitations array
invitations.push({ recipientName, eventDate, organizationName, hostName });
}
displayInvitations();
return false; // making browser not to refresh
}
// Display all invitations in the invitations array
function displayInvitations() {
const article = document.getElementById("placeholderContent");
if (invitations.length === 0) { // If invitations array is empty
article.innerHTML = 'No invitations to display';
return;
}
let html = "";
for (let i = 0; i < invitations.length; i++) {
html += `Hello ${invitations[i].recipientName}!
<br />
<br /> You have been invited to volunteer for an event held by
${invitations[i].organizationName} on
${invitations[i].eventDate}.
<br />
<br />Thanks!<br />
<br />
${invitations[i].hostName}<br /><br />`;
}
article.innerHTML = html;
}
</script>
</head>
<body>
<header>
<div class="top">
<a class="logo" href="index.html">CapellaVolunteers
<span class="dotcom">.org</span>
</a>
</div>
<nav>
<ul class="topnav">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="invitation.html" class="active">Invitation</a>
</li>
<li>
<a href="gallery.html">Gallery</a>
</li>
<li>
<a href="registration.html">Registration</a>
</li>
</ul>
</nav>
</header>
<section id="pageGlobalForm">
<form onsubmit="return processForm()">
<label for="numberOfVolunteers">Number of volunteers:</label>
<input type="number" min="1" name="numberOfVolunteers" placeholder="Enter number of volunteers" /><br />
<label for="organizationName">Organization name:</label>
<input type="text" name="organizationName" placeholder="Enter your Organization Name" /><br />
<label for="eventDate">Event Date:</label>
<input type="text" name="eventDate" placeholder="Enter your Event Date" /><br />
<label for="hostName">Host name:</label>
<input type="text" name="hostName" placeholder="Host Name" /><br />
<input type="submit" value="Submit"></form><br />
</form>
</section>
<section id="pageForm"></section>
<article id="placeholderContent"></article>
<footer>This events site is for IT-FP3215 tasks.
</footer>
</body>
</html>

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am trying to make a contact form to give input on another browser window. I...
I am trying to make a contact form to give input on another browser window. I am only getting the php code. I am trying to figure out why it won't post. Her is my html and php files: <!DOCTYPE html> <html> <head> <title>Contact</title> <link rel="stylesheet" href="main.css"> </head> <body>    <h1>Contact Form</h1> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="page2.html">My PodCast</a></li> <li><a href="page3.html">Contact Me</a></li> <li><a href="page4.html">Resources</a></li> <li><a href="addressbook.html">Address Book</a></li> <li>Contact Form</li> </ul> </nav> <center><h2>Please fill out form</h2> <div id='container'> <div id='header'></div> <center><h3>Contact</h3>...
Please linked both files. For this assignment you need to create a ToDo list using Javascript,...
Please linked both files. For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link...
Java Script I need the code to produce these 3 output. I can only get it...
Java Script I need the code to produce these 3 output. I can only get it to produce input #3 I need it to produce the following: // Input #1: // http://www.example.com // Output // http://www.example.com // Input #2: // http://www.example.com?name=r2d2 // Output // http://www.example.com // name: r2d2 // Input #3: // http://www.example.com?name=r2d2&email=r2d2%40me.com&human=no // Output // http://www.example.com // name: r2d2 // email: [email protected] // human: no THIS IS WHAT I HAVE SO FAR: HTML <!DOCTYPE html> <html lang="en"> <head> <meta...
For this assignment you'll be creating an application that has the user input a subtotal, tax...
For this assignment you'll be creating an application that has the user input a subtotal, tax rate and tip percentage and then displays the sales tax, tip amount and the total. You'll use JQuery instead of the getElementByX functions AND you will display all messages on the page (no alert or prompt boxes) The starter file is based off of the Lab 2 sales_tax application. Feel free to borrow code from your lab solution but realize you will need to...
PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you...
PART B- Javascript Using a text editor (VS Code or Notepad) and a web browser, you will demonstrate how to create an HTML file, externally link a JavaScript file, and write some source code in the JavaScript file. a..Create two blank files to be an HTML file and a JavaScript file. The file names should be partA.html and partA.js. b.. Create a basic HTML webpage structure. c..Link the JavaScript file to the HTML file using the <script> tag. d.. Prompt...
8- Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following...
8- Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following HTML tags to design your webpage <h1>…</h1> , <h3>… </h3> , <h6>… </h6> , <p>…</p> , <b> …</b> , <i>…</ i>, <a…..> </a>, <img…..> , <table>….</table> , <div> …</div>, <form>…</ form>, <input type=“text”>, and <input type=“submit”> Use an external css to change the default style of your webpage. You must use at least one element selector, one id selector, and one class selector Using...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if input from user is empty -> get an error string variable if input is not empty -> use preg_match() to match the pattern $pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/"; -> if it's a matched, get a success string variable */           } ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link...
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>         
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>                   <script src="code.js"></script>   </head>      <body onload="setFocus();">     <div class="container">                                       <div class="main">                                                                                <form action="#" method="post" name="form_name" id="form_id" class="form_class" >                                                                           <h2>--Principal Loan Form--</h2>                                                                                                                                                      <h5>Disclaimer: This software by no mean will precisely predict your mortgage through your lender company.  This Software will only assume the four items below in order to make an educated guess or prediction to your exact mortgage interests amount and the duration of your loan from your lender. <img...
Create an application that will give valuable advice to future students from someone (you!) who is...
Create an application that will give valuable advice to future students from someone (you!) who is close to graduation. However, only end-users who have their credentials validated against the database (which uses encrypted passwords) are allowed entry. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- advice_ddl.sql CREATE DATABASE advice; USE advice; CREATE TABLE users ( id int primary key auto_increment, username varchar(255), password varchar(255) ); -- insert a row into the users table: -- username = foo -- password = bar INSERT INTO users (username, password) VALUES...
*To the guy who answered last time. You're not following the directions. Please follow specific directions...
*To the guy who answered last time. You're not following the directions. Please follow specific directions below.* Create a "web page" with the following components: An input field for the "number of rounds to play" The "number of remaining" rounds should also be displayed somewhere on the screen. A button to "Start" the game play. The function attached to this button can "setup" the rest of the game. For example: initialize counters, show/hide other components, etc. A set of buttons...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT