In: Computer Science
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
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: