SlideShare a Scribd company logo
1 of 6
Download to read offline
JAVASCRIPT:
I need help adding the following to my code
Enhance the personal website you have created in the preceding chapters of this book to
include state information that will be retained from one session to the next. You can use
either web storage or cookies depending on the tools available to you. Remember that if
you use cookies you need to place your website on its own server. If your website contains
web forms that span several pages, show your mastery of query strings by adding code to
store data within query strings as users navigate from one form to the next.
Please add to existing code below
--------------------------------------------------------------------------------------
HTML FILE:
<!DOCTYPE html>
<html>
<head>
<title>Abuelita's Mexican Recipes</title>
</head>
<body>
<label id="lblGreetings"></label>
</body>
<script>
var myDate = new Date();
var hrs = myDate.getHours();
var greet;
if (hrs < 12)
greet = 'Good Morning';
else if (hrs >= 12 && hrs <= 17)
greet = 'Good Afternoon';
else if (hrs >= 17 && hrs <= 24)
greet = 'Good Evening';
document.getElementById('lblGreetings').innerHTML =
'<b>' + greet + '</b> and welcome to my page!';
</script>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Abuelita's Mexican Recipes</title>
</head>
<body>
<h3 id='image label'>A collection of abuelita's favorite recipes</h3>
<form id="myForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br>
<label for="meat">Select your favorite meats:</label>
<br>
<input type="checkbox" id="chicken" name="meat" value="chicken">
<label for="chicken">Chicken</label><br>
<input type="checkbox" id="beef" name="meat" value="beef">
<label for="beef">Beef</label><br>
<input type="checkbox" id="pork" name="meat" value="pork">
<label for="pork">Pork</label><br>
<input type="checkbox" id="fish" name="meat" value="fish">
<label for="fish">Fish</label><br>
<input type="checkbox" id="vegetarian" name="meat" value="vegetarian">
<label for="vegetarian">Vegetarian</label><br>
<button type="submit">Submit</button>
</form>
<script>
const myForm = document.getElementById("myForm");
let selectedMeats = [];
myForm.addEventListener("submit", function(event) {
event.preventDefault();
const nameInput = document.getElementById("name");
if (nameInput.value === "") {
nameInput.setCustomValidity("Please enter your name.");
} else if (nameInput.value.length < 2) {
nameInput.setCustomValidity("Please enter a valid name.");
} else {
nameInput.setCustomValidity("");
// Get the selected meats
const meatInputs = document.getElementsByName("meat");
selectedMeats = [];
for (let i = 0; i < meatInputs.length; i++) {
if (meatInputs[i].checked) {
selectedMeats.push(meatInputs[i].value);
}
}
myForm.submit();
}
});
// Remove a meat from the selectedMeats array if its checkbox is unchecked
const meatInputs = document.getElementsByName("meat");
for (let i = 0; i < meatInputs.length; i++) {
meatInputs[i].addEventListener("change", function(event) {
if (!this.checked) {
const index = selectedMeats.indexOf(this.value);
if (index !== -1) {
selectedMeats.splice(index, 1);
}
}
});
});
// Convert the selectedMeats array to a string
const selectedMeatsString = JSON.stringify(selectedMeats);
</script>
</body>
</html>
<script>
const myForm = document.getElementById("myForm");
myForm.addEventListener("submit", function(event) {
event.preventDefault();
const nameInput = document.getElementById("name");
if (nameInput.value === "") {
nameInput.setCustomValidity("Please enter your name.");
} else if (nameInput.value.length < 2) {
nameInput.setCustomValidity("Please enter a valid name.");
} else {
nameInput.setCustomValidity("");
myForm.submit();
}
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<title>Kilograms to Ounces Weight Converter</title>
<body>
<h2>Weight Converter</h2>
<p>Type a value in the Ounces field to convert the value to Cups:</p>
<p>
<label>Ounces</label>
<input id="Ounces" type="number" placeholder="Ounces" oninput="weightConverter(this.value)"
onchange="weightConverter(this.value)">
</p>
<p>Cups: <span id="outputCups"></span></p>
<script>
function weightConverter(valNum) {
try {
if (isNaN(valNum) || valNum <= 0) {
throw "Please enter a valid positive number";
}
document.getElementById("outputCups").innerHTML = valNum * 0.125;
} catch(error) {
document.getElementById("outputCups").innerHTML = error;
}
}
</script>
<html>
<head>
<meta charset="utf-8">
<title>Abuelita's Mexican Recipes</title>
</head>
<body>
<h1>Abuelita's Mexican Recipes!</h1>
<p id="greeting"></p>
<ul id="recipe-list"></ul>
<script src="Recipes.js"></script>
<script>
// Add recipes to an array
const recipes = [
new Recipe(
"Enchiladas",
"A classic Mexican dish",
["corn tortillas", "chicken", "enchilada sauce", "cheese"],
"1. Preheat oven to 350F. n2. Warm tortillas in the oven or microwave. n3. Fill each tortilla with
shredded chicken and roll up. n4. Place rolled tortillas in a baking dish, seam-side down. n5. Pour
enchilada sauce over the tortillas. n6. Sprinkle cheese on top. n7. Bake for 20-25 minutes, until
cheese is melted and bubbly."
),
new Recipe(
"Guacamole",
"A delicious avocado dip",
["avocados", "lime", "tomatoes", "onion", "jalapeo", "cilantro"],
"1. Cut avocados in half and remove pit. n2. Scoop out avocado flesh into a bowl. n3. Mash
avocado with a fork. n4. Add lime juice and salt to taste. n5. Stir in chopped tomatoes, onion,
jalapeo, and cilantro."
)
];
// Display the recipes on the page
const recipeList = document.getElementById('recipe-list');
recipes.forEach(recipe => {
const recipeItem = document.createElement('li');
recipeItem.innerHTML = `
<h2>${recipe.name}</h2>
<p>${recipe.description}</p>
<p><strong>Ingredients:</strong> ${recipe.ingredients.join(', ')}</p>
<p><strong>Instructions:</strong></p>
<ol>${recipe.instructions.split('n').map(instruction => `<li>${instruction.trim()}</li>`).join('')}</ol>
`;
recipeList.appendChild(recipeItem);
});
</script>
</body>
</html>
<a href="https://swisscyberinstitute.com/blog/10-tips-on-how-to-browse-the-internet-
safely/">Choose strict privacy and security settings on your browser</a>
<br>
<a href="https://ciso.uw.edu/education/risk-advisories/web-browsing/">Keep operating systems
and applications up to date by applying all critical software patches to protect against viruses,
spyware, and other malicious software that may infect your system through the browser.</a>
<br>
<a href="https://usa.kaspersky.com/resource-center/preemptive-safety/top-10-internet-safety-
rules-and-what-not-to-do-online">Make Sure Your Internet Connection is Secure. Use a Secure
VPN Connection.</a>
</body>
</html>
--------------------------------------------------------------------------------
JS FILE:
// Define the Recipe class
class Recipe {
constructor(name, description, ingredients, instructions) {
this.name = name;
this.description = description;
this.ingredients = ingredients;
this.instructions = instructions;
}
// Add a method to display the recipe details
display() {
console.log(`${this.name}: ${this.description}`);
console.log("Ingredients:");
for (let i = 0; i < this.ingredients.length; i++) {
console.log(`- ${this.ingredients[i]}`);
}
console.log("Instructions:");
console.log(this.instructions);
}
}
// Create some sample recipes
const recipe1 = new Recipe(
"Enchiladas",
"A classic Mexican dish",
["corn tortillas", "chicken", "enchilada sauce", "cheese"],
"1. Preheat oven to 350F. n2. Warm tortillas in the oven or microwave. n3. Fill each tortilla with
shredded chicken and roll up. n4. Place rolled tortillas in a baking dish, seam-side down. n5. Pour
enchilada sauce over the tortillas. n6. Sprinkle cheese on top. n7. Bake for 20-25 minutes, until
cheese is melted and bubbly."
);
const recipe2 = new Recipe(
"Guacamole",
"A delicious avocado dip",
["avocados", "lime", "tomatoes", "onion", "jalapeo", "cilantro"],
"1. Cut avocados in half and remove pit. n2. Scoop out avocado flesh into a bowl. n3. Mash
avocado with a fork. n4. Add lime juice and salt to taste. n5. Stir in chopped tomatoes, onion,
jalapeo, and cilantro."
);
// Display the recipe details
recipe1.display();
recipe2.display();

More Related Content

Similar to JAVASCRIPT I need help adding the following to my code Enha.pdf

Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
references
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
unodelostrece
 
View source epaper.sakshi
View source epaper.sakshiView source epaper.sakshi
View source epaper.sakshi
Diwakara Reddy
 
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfHow to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdf
Appweb Coders
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
Azharul Haque Shohan
 

Similar to JAVASCRIPT I need help adding the following to my code Enha.pdf (20)

Gail villanueva add muscle to your wordpress site
Gail villanueva   add muscle to your wordpress siteGail villanueva   add muscle to your wordpress site
Gail villanueva add muscle to your wordpress site
 
Wordpress plugin development from Scratch
Wordpress plugin development from ScratchWordpress plugin development from Scratch
Wordpress plugin development from Scratch
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
 
Client-side Transformations
Client-side TransformationsClient-side Transformations
Client-side Transformations
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
View source epaper.sakshi
View source epaper.sakshiView source epaper.sakshi
View source epaper.sakshi
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
 
User registration and login using stored procedure in php
User registration and login using stored procedure in phpUser registration and login using stored procedure in php
User registration and login using stored procedure in php
 
Advanced redux
Advanced reduxAdvanced redux
Advanced redux
 
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
Сергей Иващенко - Meet Magento Ukraine - Цены в Magento 2
 
How to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdfHow to Create Login and Registration API in PHP.pdf
How to Create Login and Registration API in PHP.pdf
 
WordCamp Manchester 2016 - Making WordPress Menus Smarter
WordCamp Manchester 2016 - Making WordPress Menus SmarterWordCamp Manchester 2016 - Making WordPress Menus Smarter
WordCamp Manchester 2016 - Making WordPress Menus Smarter
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
 
Mashing up JavaScript
Mashing up JavaScriptMashing up JavaScript
Mashing up JavaScript
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
 
Site optimization
Site optimizationSite optimization
Site optimization
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014
 
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionPemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
 

More from adinathassociates

JAVA Please help me on this method The requirement of the m.pdf
JAVA Please help me on this method The requirement of the m.pdfJAVA Please help me on this method The requirement of the m.pdf
JAVA Please help me on this method The requirement of the m.pdf
adinathassociates
 

More from adinathassociates (20)

It is somewhat curious that this documentation does not wind.pdf
It is somewhat curious that this documentation does not wind.pdfIt is somewhat curious that this documentation does not wind.pdf
It is somewhat curious that this documentation does not wind.pdf
 
izgi ynteminin ve nceden alanm plakann sonularna gre k.pdf
izgi ynteminin ve nceden alanm plakann sonularna gre k.pdfizgi ynteminin ve nceden alanm plakann sonularna gre k.pdf
izgi ynteminin ve nceden alanm plakann sonularna gre k.pdf
 
Jamie needs a new roof on her house The cash cost is 4100.pdf
Jamie needs a new roof on her house The cash cost is 4100.pdfJamie needs a new roof on her house The cash cost is 4100.pdf
Jamie needs a new roof on her house The cash cost is 4100.pdf
 
It is necessary for Marketers to know how the customers feel.pdf
It is necessary for Marketers to know how the customers feel.pdfIt is necessary for Marketers to know how the customers feel.pdf
It is necessary for Marketers to know how the customers feel.pdf
 
James tiene la enfermedad celaca Cul de los siguientes a.pdf
James tiene la enfermedad celaca Cul de los siguientes a.pdfJames tiene la enfermedad celaca Cul de los siguientes a.pdf
James tiene la enfermedad celaca Cul de los siguientes a.pdf
 
It is difficult to quantify a value for certain biological a.pdf
It is difficult to quantify a value for certain biological a.pdfIt is difficult to quantify a value for certain biological a.pdf
It is difficult to quantify a value for certain biological a.pdf
 
It was leaked that Bergdorf Goodman treated Kayla a Hispanic.pdf
It was leaked that Bergdorf Goodman treated Kayla a Hispanic.pdfIt was leaked that Bergdorf Goodman treated Kayla a Hispanic.pdf
It was leaked that Bergdorf Goodman treated Kayla a Hispanic.pdf
 
It is possible to create dynamic GUI applications based on c.pdf
It is possible to create dynamic GUI applications based on c.pdfIt is possible to create dynamic GUI applications based on c.pdf
It is possible to create dynamic GUI applications based on c.pdf
 
Joe makes annual income of 5000 for five years Joe withdr.pdf
Joe makes annual income of 5000 for five years Joe withdr.pdfJoe makes annual income of 5000 for five years Joe withdr.pdf
Joe makes annual income of 5000 for five years Joe withdr.pdf
 
Joan Robinson ktisat okumann amac iktisat sorularna bir d.pdf
Joan Robinson ktisat okumann amac iktisat sorularna bir d.pdfJoan Robinson ktisat okumann amac iktisat sorularna bir d.pdf
Joan Robinson ktisat okumann amac iktisat sorularna bir d.pdf
 
Jobyde ie alma ilerleme terfi ve tevik etme grevleri gen.pdf
Jobyde ie alma ilerleme terfi ve tevik etme grevleri gen.pdfJobyde ie alma ilerleme terfi ve tevik etme grevleri gen.pdf
Jobyde ie alma ilerleme terfi ve tevik etme grevleri gen.pdf
 
It is not option 3 please help What would be the outcome of.pdf
It is not option 3 please help What would be the outcome of.pdfIt is not option 3 please help What would be the outcome of.pdf
It is not option 3 please help What would be the outcome of.pdf
 
Joanna and Chip Gaines and Michael Dubin got together recent.pdf
Joanna and Chip Gaines and Michael Dubin got together recent.pdfJoanna and Chip Gaines and Michael Dubin got together recent.pdf
Joanna and Chip Gaines and Michael Dubin got together recent.pdf
 
JKL Co issues zero coupon bonds on the market at a price of.pdf
JKL Co issues zero coupon bonds on the market at a price of.pdfJKL Co issues zero coupon bonds on the market at a price of.pdf
JKL Co issues zero coupon bonds on the market at a price of.pdf
 
Jill is offered a choice between receiving 50 with certaint.pdf
Jill is offered a choice between receiving 50 with certaint.pdfJill is offered a choice between receiving 50 with certaint.pdf
Jill is offered a choice between receiving 50 with certaint.pdf
 
Jennys Froyo INC Balance Sheet For Year Ended December 31.pdf
Jennys Froyo INC Balance Sheet For Year Ended December 31.pdfJennys Froyo INC Balance Sheet For Year Ended December 31.pdf
Jennys Froyo INC Balance Sheet For Year Ended December 31.pdf
 
Jim y Sue se iban a casar y estaban muy enamorados Antes de.pdf
Jim y Sue se iban a casar y estaban muy enamorados Antes de.pdfJim y Sue se iban a casar y estaban muy enamorados Antes de.pdf
Jim y Sue se iban a casar y estaban muy enamorados Antes de.pdf
 
Jhania Bive the muk hroutwes ite p+4i if peras bt in +45 te.pdf
Jhania Bive the muk hroutwes ite p+4i if peras bt in +45 te.pdfJhania Bive the muk hroutwes ite p+4i if peras bt in +45 te.pdf
Jhania Bive the muk hroutwes ite p+4i if peras bt in +45 te.pdf
 
JAVA Please help me on this method The requirement of the m.pdf
JAVA Please help me on this method The requirement of the m.pdfJAVA Please help me on this method The requirement of the m.pdf
JAVA Please help me on this method The requirement of the m.pdf
 
Jennifer invested the profit of his business in an investmen.pdf
Jennifer invested the profit of his business in an investmen.pdfJennifer invested the profit of his business in an investmen.pdf
Jennifer invested the profit of his business in an investmen.pdf
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

JAVASCRIPT I need help adding the following to my code Enha.pdf

  • 1. JAVASCRIPT: I need help adding the following to my code Enhance the personal website you have created in the preceding chapters of this book to include state information that will be retained from one session to the next. You can use either web storage or cookies depending on the tools available to you. Remember that if you use cookies you need to place your website on its own server. If your website contains web forms that span several pages, show your mastery of query strings by adding code to store data within query strings as users navigate from one form to the next. Please add to existing code below -------------------------------------------------------------------------------------- HTML FILE: <!DOCTYPE html> <html> <head> <title>Abuelita's Mexican Recipes</title> </head> <body> <label id="lblGreetings"></label> </body> <script> var myDate = new Date(); var hrs = myDate.getHours(); var greet; if (hrs < 12) greet = 'Good Morning'; else if (hrs >= 12 && hrs <= 17) greet = 'Good Afternoon'; else if (hrs >= 17 && hrs <= 24) greet = 'Good Evening'; document.getElementById('lblGreetings').innerHTML = '<b>' + greet + '</b> and welcome to my page!'; </script> </html> <html> <head> <meta charset="utf-8"> <title>Abuelita's Mexican Recipes</title> </head> <body> <h3 id='image label'>A collection of abuelita's favorite recipes</h3> <form id="myForm"> <label for="name">Name:</label>
  • 2. <input type="text" id="name" name="name" required> <br> <label for="meat">Select your favorite meats:</label> <br> <input type="checkbox" id="chicken" name="meat" value="chicken"> <label for="chicken">Chicken</label><br> <input type="checkbox" id="beef" name="meat" value="beef"> <label for="beef">Beef</label><br> <input type="checkbox" id="pork" name="meat" value="pork"> <label for="pork">Pork</label><br> <input type="checkbox" id="fish" name="meat" value="fish"> <label for="fish">Fish</label><br> <input type="checkbox" id="vegetarian" name="meat" value="vegetarian"> <label for="vegetarian">Vegetarian</label><br> <button type="submit">Submit</button> </form> <script> const myForm = document.getElementById("myForm"); let selectedMeats = []; myForm.addEventListener("submit", function(event) { event.preventDefault(); const nameInput = document.getElementById("name"); if (nameInput.value === "") { nameInput.setCustomValidity("Please enter your name."); } else if (nameInput.value.length < 2) { nameInput.setCustomValidity("Please enter a valid name."); } else { nameInput.setCustomValidity(""); // Get the selected meats const meatInputs = document.getElementsByName("meat"); selectedMeats = []; for (let i = 0; i < meatInputs.length; i++) { if (meatInputs[i].checked) { selectedMeats.push(meatInputs[i].value); } } myForm.submit(); } }); // Remove a meat from the selectedMeats array if its checkbox is unchecked const meatInputs = document.getElementsByName("meat"); for (let i = 0; i < meatInputs.length; i++) {
  • 3. meatInputs[i].addEventListener("change", function(event) { if (!this.checked) { const index = selectedMeats.indexOf(this.value); if (index !== -1) { selectedMeats.splice(index, 1); } } }); }); // Convert the selectedMeats array to a string const selectedMeatsString = JSON.stringify(selectedMeats); </script> </body> </html> <script> const myForm = document.getElementById("myForm"); myForm.addEventListener("submit", function(event) { event.preventDefault(); const nameInput = document.getElementById("name"); if (nameInput.value === "") { nameInput.setCustomValidity("Please enter your name."); } else if (nameInput.value.length < 2) { nameInput.setCustomValidity("Please enter a valid name."); } else { nameInput.setCustomValidity(""); myForm.submit(); } }); </script> </body> </html> <!DOCTYPE html> <html> <title>Kilograms to Ounces Weight Converter</title> <body> <h2>Weight Converter</h2> <p>Type a value in the Ounces field to convert the value to Cups:</p> <p> <label>Ounces</label> <input id="Ounces" type="number" placeholder="Ounces" oninput="weightConverter(this.value)" onchange="weightConverter(this.value)"> </p>
  • 4. <p>Cups: <span id="outputCups"></span></p> <script> function weightConverter(valNum) { try { if (isNaN(valNum) || valNum <= 0) { throw "Please enter a valid positive number"; } document.getElementById("outputCups").innerHTML = valNum * 0.125; } catch(error) { document.getElementById("outputCups").innerHTML = error; } } </script> <html> <head> <meta charset="utf-8"> <title>Abuelita's Mexican Recipes</title> </head> <body> <h1>Abuelita's Mexican Recipes!</h1> <p id="greeting"></p> <ul id="recipe-list"></ul> <script src="Recipes.js"></script> <script> // Add recipes to an array const recipes = [ new Recipe( "Enchiladas", "A classic Mexican dish", ["corn tortillas", "chicken", "enchilada sauce", "cheese"], "1. Preheat oven to 350F. n2. Warm tortillas in the oven or microwave. n3. Fill each tortilla with shredded chicken and roll up. n4. Place rolled tortillas in a baking dish, seam-side down. n5. Pour enchilada sauce over the tortillas. n6. Sprinkle cheese on top. n7. Bake for 20-25 minutes, until cheese is melted and bubbly." ), new Recipe( "Guacamole", "A delicious avocado dip", ["avocados", "lime", "tomatoes", "onion", "jalapeo", "cilantro"], "1. Cut avocados in half and remove pit. n2. Scoop out avocado flesh into a bowl. n3. Mash avocado with a fork. n4. Add lime juice and salt to taste. n5. Stir in chopped tomatoes, onion, jalapeo, and cilantro."
  • 5. ) ]; // Display the recipes on the page const recipeList = document.getElementById('recipe-list'); recipes.forEach(recipe => { const recipeItem = document.createElement('li'); recipeItem.innerHTML = ` <h2>${recipe.name}</h2> <p>${recipe.description}</p> <p><strong>Ingredients:</strong> ${recipe.ingredients.join(', ')}</p> <p><strong>Instructions:</strong></p> <ol>${recipe.instructions.split('n').map(instruction => `<li>${instruction.trim()}</li>`).join('')}</ol> `; recipeList.appendChild(recipeItem); }); </script> </body> </html> <a href="https://swisscyberinstitute.com/blog/10-tips-on-how-to-browse-the-internet- safely/">Choose strict privacy and security settings on your browser</a> <br> <a href="https://ciso.uw.edu/education/risk-advisories/web-browsing/">Keep operating systems and applications up to date by applying all critical software patches to protect against viruses, spyware, and other malicious software that may infect your system through the browser.</a> <br> <a href="https://usa.kaspersky.com/resource-center/preemptive-safety/top-10-internet-safety- rules-and-what-not-to-do-online">Make Sure Your Internet Connection is Secure. Use a Secure VPN Connection.</a> </body> </html> -------------------------------------------------------------------------------- JS FILE: // Define the Recipe class class Recipe { constructor(name, description, ingredients, instructions) { this.name = name; this.description = description; this.ingredients = ingredients; this.instructions = instructions; } // Add a method to display the recipe details display() {
  • 6. console.log(`${this.name}: ${this.description}`); console.log("Ingredients:"); for (let i = 0; i < this.ingredients.length; i++) { console.log(`- ${this.ingredients[i]}`); } console.log("Instructions:"); console.log(this.instructions); } } // Create some sample recipes const recipe1 = new Recipe( "Enchiladas", "A classic Mexican dish", ["corn tortillas", "chicken", "enchilada sauce", "cheese"], "1. Preheat oven to 350F. n2. Warm tortillas in the oven or microwave. n3. Fill each tortilla with shredded chicken and roll up. n4. Place rolled tortillas in a baking dish, seam-side down. n5. Pour enchilada sauce over the tortillas. n6. Sprinkle cheese on top. n7. Bake for 20-25 minutes, until cheese is melted and bubbly." ); const recipe2 = new Recipe( "Guacamole", "A delicious avocado dip", ["avocados", "lime", "tomatoes", "onion", "jalapeo", "cilantro"], "1. Cut avocados in half and remove pit. n2. Scoop out avocado flesh into a bowl. n3. Mash avocado with a fork. n4. Add lime juice and salt to taste. n5. Stir in chopped tomatoes, onion, jalapeo, and cilantro." ); // Display the recipe details recipe1.display(); recipe2.display();