Question

Develop and test an HTML document that has text boxes for apple (69 cents each), orange...

Develop and test an HTML document that has text boxes for apple (69 cents each), orange (59 cents each), and banana (49 cents each), along with a Submit button. These text boxes take a number, which is the purchased number of the particular fruit. Add a max property value of 99 and a min property value of 0. Add event handlers using the min and max properties to check on values input through the text boxes of the document to ensure that the input values are numbers in the range. Each of the text boxes should have its own onclick event handler. These handlers must add the cost of their fruit to a total cost. An event handler for the Submit button must produce an alert window with the message "Your total cost is $xxx.xx" where xxx.xx is the total cost of the chosen fruit, including 7.75 percent sales tax. This handler must return false (to avoid actual submission of the form data).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

<!DOCTYPE html>
<html>
<head>
   <title>Shopping Cart</title>
</head>
<body>
   <div>
       <form>
           <label>Apples (69 cents each) : </label>
           <input type="textbox" id="apples" name="apples" value="" min="0" max="99" onkeyup="applemax(this.value);"><br>
           <label>Oranges (59 cents each) : </label>
           <input type="textbox" id="oranges" name="oranges" value="" min="0" max="99" onkeyup="orangemax(this.value);"><br>
           <label>Banana (49 cents each) : </label>
           <input type="textbox" id="bananas" name="bananas" value="" min="0" max="99" onkeyup="bananamax(this.value);"><br>
           <input type="button" id="calculate" value="Submit">
       </form>
   </div>
   <script type="text/javascript">
       function calc() {

           var apple = document.getElementsByName("apples")[0].value;
           var orange = document.getElementsByName("oranges")[0].value;
           var banana = document.getElementsByName("bananas")[0].value;

           total = (apple * ".69" + orange * ".59" + banana * ".49" ) * "1.0775";
           // The 1.0775 is to calculate the percent sales tax

           alert("Your total cost is $" + total.toPrecision(5));
       }

       function applemax(value)
       {

           var maxValue = 99;
           if( value> maxValue ) // checking the value in the text box
           {
               alert("The input can be in the range of 0-99"); // alert if the input is more than 99
               apples.value="0"; // changing the value to 0 if value is more than 99
           }
       }

       function orangemax(value)
       {

           var maxValue = 99;
           if( value> maxValue )
           {
               alert("The input can be in the range of 0-99");
               oranges.value="0";
           }
       }

       function bananamax(value)
       {

           var maxValue = 99;
           if( value> maxValue )
           {
               alert("The input can be in the range of 0-99");
               bananas.value="0";
           }
       }

       window.onload = function () {
           document.getElementById("calculate").onclick = calc;
       };

   </script>
</body>
</html>

Apples (69 cents each): 6 Oranges (59 cents each) 6 Banana (49 cents each): 0 The input can be in the range of 0-99 OK SubmitCybrary Wonder Apps Gmail Sign in to GitHub Adderall Substitute... Open Bioinformatic.. This page says Apples (69 cents each)

Add a comment
Know the answer?
Add Answer to:
Develop and test an HTML document that has text boxes for apple (69 cents each), orange...
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
  • develop and test an html document that has text boxes for apples orange and banana, along...

    develop and test an html document that has text boxes for apples orange and banana, along with a submit button. these boxes take a number which is purchased number of the particular fruit. each of the text boxes should have its own onclick event handler. these handlers must add the cost of their fruit to a total cost. an event handler for the submit button must produce an alert window with the message: your total cost is $xyz id the...

  • can you do this js and html question. ill give you the html and js and...

    can you do this js and html question. ill give you the html and js and css files just fix my error use if and else like what i did dont use switch just fix my erorr. <!DOCTYPE html> <!-- Webpage HTML document for Lab 4. Authors: Amirhossein Chinaei, Andriy Pavlovych For: EECS 1012, York University, Lassonde School of Engineering --> <html lang="En"> <head> <meta charset="UTF-8"> <!-- title for web page --> <title> EECS1012: Lab 4 - Computational Thinking </title>...

  • given below are the project description and their Html and css files i need javascript according...

    given below are the project description and their Html and css files i need javascript according to the project and other files! WEB230 - JavaScript 1 Assignment 6b - Event Delegation Before starting, study the HTML and open it in a browser so that you understand the structure of the document. You will add functionality to perform several tasks in our shopping list app. Clicking the red "X" at the right of an item will delete that item. Clicking on...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • please help witb coding! this is a beginner level class! second picture is what it is...

    please help witb coding! this is a beginner level class! second picture is what it is suppose to look like 3 - A A A EVENE Äv 21 Never email your code to anyone. Maintain the standards of academic honesty discussed in lecture and in previous labs. The work you turn in must be your work not copied from anywhere. • You should use Firefox or Chrome for the browser for testing your code, NOT Internet Explorer. Part I-lab12xxx.html -...

  • i need the code that goes within the <script> opening and closing following the insturctions of...

    i need the code that goes within the <script> opening and closing following the insturctions of the insturctions of the pasted assignment screen shots please. <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 3 Hands-on Project 3-1 Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Hands-on Project 3-1</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 3-1 </h1> </header> <article> <h2>Lunch selections</h2> <form> <input type="checkbox" id="item1" value="8" /> <label for="item1">Fried chicken ($8.00)</label> <input type="checkbox"...

  • New Perspectives on HTML5 and CSS3. Solve Chapter 13 Case Problem 3. mas_register.js "use strict"; /*...

    New Perspectives on HTML5 and CSS3. Solve Chapter 13 Case Problem 3. mas_register.js "use strict"; /* New Perspectives on HTML5, CSS3, and JavaScript 6th Edition Tutorial 13 Case Problem 3 Filename: mas_register.js Author: Date: Function List ============= formTest() Performs a validation test on the selection of the conference session package and the conference discount number calcCart() Calculates the cost of the registration and saves data in session storage    writeSessionValues() Writes data values from session storage in to the registration...

  • need this in #c . You will now add server side validation code to the frmPersonnel...

    need this in #c . You will now add server side validation code to the frmPersonnel page. Currently, when the Submit button is pressed, the frmPersonnelVerified page is displayed. This is because the frmPersonnelVerified page is set as the Submit button's PostBackUrl property. Instead of having the page go directly to the frmPersonnelVerified page when the Submit button is pressed, we want to do some server side validation. If any of the validation rules fail, we will redisplay the frmPersonnel...

  • 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...

  • Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php...

    Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php script, create an associative array named $order that stores the following values: - the number of cheese toppings; - the number of pepperoni toppings; - the number of ham toppings; - the size of the ordered pizza; - the number of the ordered pizza; - the total cost of the order; - the discount rate; - the total cost after the discount. 2) the...

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