Question

In: Computer Science

Write a javascript code to Create a function called Hotel that takes Room no, Customer name....

Write a javascript code to Create a function called Hotel that takes Room no, Customer name. amount paid. Write a code to call hotel function for each customer and display details of customers lodging in rooms with even room numbers.
I need only js and html code. no css
pls take screenshot of output , else I might dislike
thanks

Solutions

Expert Solution

As you mentioned, I prepared the code only using the required javascript funtion with required parameters and the html code.

Here How it works:

1. Whenever a new customer visit hotel, he enters his/her details in provided form, and clicking on "Book Room" button his detail will be shown on html page with the help of javascript function:

----------------------------------------------------------------------------------------------------------------

Code:

<!DOCTYPE html>
<html>
<body>

<h3>Welcome to Hotel</h3>

<form >
<label for="fname">Room number:</label><br>
<input type="text" id="room" ><br>
<label for="lname">Customer name:</label><br>
<input type="text" id="na"><br>
<label for="lname">Amount Paid:</label><br>
<input type="text" id="amt" ><br><br>
<input type="button" value="Book Room" onclick="Hotel(room.value,na.value, amt.value)">
</form>

<p id="addDetails"></p>

<script>
//This is the function that will print details of each customer on screen
function Hotel(room_num, name,amount) {

var str = "<b>Booked Room Number: " + room_num + "</b><br/>Name: " + name + "<br/>Amount Paid: $" + amount + "<br/><br/>";
document.getElementById("addDetails").innerHTML += str;
}
</script>

</body>
</html>

-----------------------------------------------------------------------------------------------------

Output:


Related Solutions

JavaScript Write a function called "first" that takes in two arguments - the first is an...
JavaScript Write a function called "first" that takes in two arguments - the first is an argument called arr that is an array of numbers, the second is an optional number argument called num(hint: you'll need a default value - look back at the slides). If "num" was not passed in (since it's optional), the "first" function will return an array containing the first item of the array. If a value for "num" was given, the "first" function will return...
write an algorithm function called balance() in javascript that takes in a string and returns a...
write an algorithm function called balance() in javascript that takes in a string and returns a strinf with balanced parantheses only. the string should be able to contain only parantheses, numbers, and letters. include comments of each portion of your code balance(“()()”) should return “()()” balance(“())”) should return “()” balance(“a(b)c”) should return “a(b)c” balance(“a(b)c())”) should return “a(b)c()”
Write a function (in Javascript) called longestMorseCodeWords which takes in an array of strings. The output...
Write a function (in Javascript) called longestMorseCodeWords which takes in an array of strings. The output of longestMorseCodeWords should be an array of the strings that were passed in, but ordered by the length of their Morse Code equivalent in descending order. If the length of Morse Code is equal, order the words alphabetically.For convenience, the full table for the 26 letters of the English alphabet is given below: [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."] let words = ["gin", "zen", "gig", "msg"] longestMorseCodeWords(words) The Morse...
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of...
Write a function called fnReadInParameters() that takes as parameter(s): • a string indicating the name of the parameter le This function should return a dictionary that stores all of the parameter le data of the SIR model in a format that we will describe further below.
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts a Date object dateStr and returns a string that is the day of the week in English form (i.e. “Sunday”, “Monday”, etc.). Test your function by creating a date object that is a significant date to you (such as your birthday) and passing that date object to your function. Test your function at least twice with two different dates. Submit the dayOfWeek.js file to...
Python Programming 1. Write a function name split_name which takes one parameter called name. If the...
Python Programming 1. Write a function name split_name which takes one parameter called name. If the name parameter value is a name in the form LastName, FirstName(e.g., ”Grounds, Nic”) then the function should return a list of two elements where FirstName is the first element and LastName is the second element. If the name parameter value is a name in the form FirstName LastName(e.g., ”Nic Grounds”) then the function should return a list of two elements where FirstName is the...
Making a blackjack game in javascript Create a function called createDeck() that will create an array...
Making a blackjack game in javascript Create a function called createDeck() that will create an array of objects (52). Each object contains two properties: suit and value. The suit property will be either 'Hearts', 'Clubs', 'Diamonds', or 'Spades'. The value property will be either 'Ace', 'King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven', 'Six', 'Five', 'Four', 'Three' , or 'Two''. Note: We will probably want to store possible suits and values in separate arrays. Create a function called shuffleDeck() that will...
Write a python function image compress() that takes one argument called filename, which is the name...
Write a python function image compress() that takes one argument called filename, which is the name of a file that contains a N × N (N-pixel by N-pixel) “grayscale bitmap image”. A “grayscale bitmap image” is an image of the following form where every pixel contains a grayscale color value between 0 − 255 (inclusive). Colour value 0 means that pixel should appear completely black and color value 255means completely white. Any other value in between stands for different shades...
Using JavaScript for the following assignment Design and code a function named "intersection" that takes two...
Using JavaScript for the following assignment Design and code a function named "intersection" that takes two arrays of numbers in parameter and returns a new array containing only the values that are both in the two arrays. A value must not be found more than once in the resulting array but can be found more than once in the arrays in parameter. The order of the elements in the resulting array must respect the order of the first parameter. For...
Part 2 Write a C code to create a user defined function called RecArea that will...
Part 2 Write a C code to create a user defined function called RecArea that will calculate the area of a rectangle. Call the function to print the area of the rectangle on the screen. Note: The user will enter the length and width of a rectangle (decimal values, float) and you Part 3 (Continue on part 2) Create another user defined function called TriArea that will calculate the area of a triangle. Print the area of the rectangle on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT