Question

Your page will simulate a reservation form for a hotel stay. It should include the following:

  • Name à Text field
  • Email à Text field
  • Number of nights à Text field (of size 3)
  • Type of room? à Select box with options for Regular ($100), Deluxe ($150), Suite ($250)
  • Would you like to join our Frequent Travellers Club? If you join, we will take $50 off your first order. à Checkbox

Write the function that will confirm what the user requested. You should output the total cost of their order. You should output this information to the <div> section called ‘results’.

For example, if the user wanted to stay for 3 nights and chose the "deluxe room", and checked the frequent travellers club, you would output the following:

Thank you, NAME for your reservation! You are staying for 3 nights in a deluxe room. We will add you to our Frequent Travellers Club. The total cost of your stay is $400.00.

Comfort Corner Suites Name: Yosef Mendelsohn Email: ymendels@depaul.edu Number of Nights: 3 Type of Room? Deluxe ($150 per ni

Note: The cost was arrived at by: 3 nights * $150 per night, minus $50 for joining the frequent travllers club.

Note: If the user chooses only 1 night, you don't have to worry about saying "night" v.s. "nights". That is, it's okay if you use the plural form for each.

Include the functionality mentioned above so that if they choose more than 1 night, you output "nights", but if they only choose 1 night you output "night".

Important Tip: Remember to start very, very small on the concatenation and build. That is, don't try to do it all at once. Start in pieces and build it until it all comes together.

Hints:

  • you will want a variable to keep track of the cost, and to adjust it as you see what's in the form (e.g. number of nights, type of room, etc.)
  • You will want an if/else if sequence to figure out the which room they chose and then will multiply by the number of nights.
  • You will probably want a separate single if block for the frequent travellers club.
  • Your version may be different from what I have offered in these tips, yet still be perfectly correct.

Other Requirements:

  • You MUST use "else if" for the room types in your JavaScript. That is, I do not want to see separate 'if' statements. There should be one "if" and two "else if" statements.
  • Output to 2 decimal places (since this is a monetary amount). Recall that there is a method called toFixed() that allows you to do this.
  • Set the width of your entire page to 450 pixels. You can do this by applying your style to the <body> tag. Note: Some feel that styling the <body> tag is not the ideal way to do this, but let's keep it relatively simple for now.
  • Using a contextual selector, style the results section so that any text inside is displayed in italics. This section should also have a red border that is 2 pixels wide. The background color of the section should be blue, and the foreground should be white. (If you'd like to choose different colors, that's fine too).
  • Experiment with padding and/or margins to make your section a little 'cleaner'. That is, without using these features, you may find that the text abuts directly against the border. Using borders or padding can help clean it up a little.
  • All styling must be done in an external style sheet.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Simple Explanation :

We are going to use different input type so as to make sure that the required need is fullfilled and a appropiate label likewise. Simple but effective way of handling the tags is embedding them with the specific id which can be further used in the javascript section.As it is very clear from the question itself and every steps are explained in details in the question. Some extra feature added like if we try to click the reserve button with filling details it would "Please fill up details". we can get the values of the tag by using

var value=document.getElementById("id-name").value;

The above equation fetch's the value from the webpage and stores it in the variable itself and then we can use it like any other variable.

We had attached the script file and css file to the HTML.

NOTE: Make sure, all the three files should be saved in the same directory(HTML FILE, CSS FILE , JS FILE).

Everything is given below with screenshot and code

HTML CODE:

Reservation.html

<!DOCTYPE html>
<html>
<head>
   <title>Hotel Reservation Form</title>
   <link rel="stylesheet" type="text/css" href="Reservation.css">
</head>
<body>
   <h1>Comfort Corner Suites</h1>
   <div>
       <label>Name:</label>
       <input type="name" name="name" id="name">
   </div>
   <br>
   <div>
       <label>Email:</label>
   <input type="Email" name="Email" id="email">
   </div>
   <br>
   <div>
       <label>Number of Nights:</label>
       <input type="Number" name="numberOfNights" id="numberOfNights">
   </div>
   <br>
   <div>
       <label>Type of Room?</label>
       <select id="room">
           <option value="100">Regular($100 per night)</option>
           <option value="150">Deluxe($150 per night)</option>
           <option value="250">Suite($250 per night)</option>
       </select>
   </div>
   <br>
   <div>
       <label>Would you like to join our Frequent Travellers Club? If you join, we will take $50 off your first order.</label>
       <input type="checkbox" name="club" id="club">
   </div>
   <br>
   <input type="button" onclick="Reserve()" value="Reserve My Room!">
   <br>
   <br>
  
   <div id="result" style="visibility: hidden;"></div>

   <script type="text/javascript" src="Reservation.js"></script>
</body>
</html>

CSS CODE:

Reservation.css

body{
   text-align: center;
   border:2px black solid;
   margin:100px;
   padding: 10px;
   width: 450px;
}
#result{
   border:2px red solid;
   background-color: blue;
   color: white;
   font-style: italic;
}

JAVASCRIPT CODE:

Reservation.js

function Reserve() {

   var room=document.getElementById('room').value;
   var name=document.getElementById('name').value;
   var email=document.getElementById('email').value;
   var numberOfNights=document.getElementById('numberOfNights').value;
   var club=document.getElementById('club').checked;


   var roomType;

   if (room=="150") {
       roomType="deluxe";
   }
   else if (room=="100") {
       roomType="regular";
   }
   else{
       roomType="suite";
   }


   var memberClub,discount;

   if (club) {
       discount=50;
       memberClub=" We will add you to our Frequent Travellers Club.";
   }
   else{
       discount=0;
       memberClub="";
   }
   var totalCostOfStay=0;

   totalCostOfStay=numberOfNights*room-discount;

   var showNight;

   if (numberOfNights>1) {
       showNight="nights";
   }
   else{
       showNight="night";
   }

   if (name!="" && email!="" && numberOfNights!="") {
       document.getElementById('result').style.visibility = "visible";
       document.getElementById('result').innerHTML="Thank you, "+name+" for your reservation! You are staying for "+
                                               numberOfNights+" "+showNight+" in a "+roomType+" room."+memberClub+
                                               " The total cost of your stay is $"+totalCostOfStay+".0.";
   }
   else{
       alert("Please, fill up all details!!!");
   }

  
}

OUTPUT :

Comfort Corner Suites Name: Ashish Singh Email: test123@gmail.com Number of Nights: 3 Type of Room? Deluxe($150 per night) Wo

CODE SCREENSHOT :

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45X Reservation.css х Reservation.html Reservation.js function Reserve() { 1 2 var room=document.getElementById(room).value;totalCostofStay=numberOfNights room-discount; var showNight; if (numberOfNights>1) { showNight=nights; } else{ showNight=nReservation.html х Reservation.js х Reservation.css X 1 2 In A 0 0 body{ text-align: center; border:2px black solid; margin:1Please provide feedback and comment down if any problem arises.

Add a comment
Know the answer?
Add Answer to:
Your page will simulate a reservation form for a hotel stay. It should include the following:...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create an HTML5 page that contains a form to collect the following data. The text in...

    Create an HTML5 page that contains a form to collect the following data. The text in bold indicates the id value that should be assigned to each html control: Product (drop down list) product – iPad, iPhone 6S, Galaxy 5S, Moto X, and so on Quantity (number) quantity Unit price (number) unit_price Discount (%)(number) discount_rate Date (date)   order_date First Name (text box)   first_name Last Name (text box)   last_name Payment type (drop down list)   payment_type – Visa, Master, Discover, Amex, and...

  • Assignment:Super Lotto This exercise is JavaScript only. No jQuery, please. Your page should work as follows: Ask the user the highest number that they want to generate. (Some lotteries are 1 ‐ 47, so...

    Assignment:Super Lotto This exercise is JavaScript only. No jQuery, please. Your page should work as follows: Ask the user the highest number that they want to generate. (Some lotteries are 1 ‐ 47, some 1 ‐ 49, etc.) Ask the user how many numbers they want to generate. Create a function that returns a random number between 1 and the highest number (see "Additional Info" below). Create an array of numbers. Run the function the correct number of times, putting...

  • HTML / CSS Content Requirements Create a home page with the following elements and settings: Set...

    HTML / CSS Content Requirements Create a home page with the following elements and settings: Set the background, font colors, and “theme” to match those used in lab assignment #1 using an external css file; inline styling should be used only where necessary to override styling from the external css H1 element, centered at the top of the page, with “Thank you for choosing Your Company Name. . . “ text* Div or other container with at least 5 sentences...

  • 2. HTMIICSS Coding Write the XHITMI and CSS code necessary to recreate the following appearance on-screen. Adaprted from the WA.B.L page of the Washington Beer Commision webrite, washingtonbeer.c...

    2. HTMIICSS Coding Write the XHITMI and CSS code necessary to recreate the following appearance on-screen. Adaprted from the WA.B.L page of the Washington Beer Commision webrite, washingtonbeer.com ashington Home of the WASHINGTON BEER Commission What is WA.B.L? WA.DL, is a community of WAshington Ber Lovers celebrating the FRESH LOCAL AWARD WINNING c rah beer produced Its a Washingtion Deer Fan Club WA.B.L. Perks WABL neems, and oner businesses prometing lanty Washngton beer Each hirt with a design unique to...

  • Hello, this is my code. moest of the things works but when select the price, i...

    Hello, this is my code. moest of the things works but when select the price, i just dont get my total. can someone help me out . thank you My queshion is also here The page will simulate the site for a Chicago-based small bus line that travels to St Louis, Milwaukee, and Detroit. Here are the requirements: The home page (i.e. the main page) should simply be the heading, image, and slogan of the site.  The home page should NOT...

  • making a file You are tasked with creating a text-based program for storing data on Hotel...

    making a file You are tasked with creating a text-based program for storing data on Hotel Room Bookings - however, as this is a comparative languages course, you will be creating the same application in the following three programming languages: • Java, • Python, and • Lisp As you implement the application in each language you should keep notes on: - The features of the languages used, - Which features you found useful, and - Any issues or complications which...

  • IF YOU ZOOM IN ON THE PICTURES ON YOUR COMPUTER YOU SHOULD BE ABLE TO SEE...

    IF YOU ZOOM IN ON THE PICTURES ON YOUR COMPUTER YOU SHOULD BE ABLE TO SEE THEM. The project is based on TripAdvisor content and reviews the goal is to modify the code so that it uses sets to find out which negative words were used throughout the whole 20 reviews please adjust your code for the following changes -- The data file for this project (attached) contains 20 reviews rather than 3 reviews Each review occupies 13 lines rather...

  • My question is about the case study “ Comparing Apples and Oranges: which group yuelds the...

    My question is about the case study “ Comparing Apples and Oranges: which group yuelds the best profit?” 1) Using the Excel apreadsheet attached to complete the rooms sold and revenue projections based on the above case study. Case Study: "Comparing Apples and Oranges: Which Group Yields the Best Profit?" ​The Diamond Peak Hotel, one of 45 hotels in the Host Marriott management company, was bustling with business this Thursday afternoon as the hour of the daily revenue meeting drew...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT