Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Calculating a total from a form

Calculating a total from a form

Scheduled Pinned Locked Moved JavaScript
javascripthtmlcsstoolsarchitecture
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tristarterror
    wrote on last edited by
    #1

    Not sure what I'm missing here. When I click the Total Cost button nothing appears in the text input. I've looked over the documents for any syntax errors but I am just not finding it!! This is an assignment. I need to the total to be inside the input text box. I'm just looking for another set of eyes to see if I missed a semicolon or something simple somewhere. HTML:

    <!DOCTYPE html>
    <!--
    A document for exercise5-3.js

    Author: Trista Woods
    Date: 27 June 2013
    LOG:
    

    -->
    <html lang="en">
    <head>
    <title>Woods | Order Total | Execise 5.3</title>
    <meta charset="utf-8" />
    <script type="type/javascript" src="j/exercise5-3.js">
    </script>

    <!-- revert to external css -->
    <style type="text/css">
        td, th, table {border: thin solid black;}
    </style>
    

    </head>
    <body>
    <form action = "">
    <h3>Produce Order Form</h3>
    <!-- A bordered table for item orders -->
    <table>
    <tr>
    <th>Type of Produce</th>
    <th>Price</th>
    <th>Quantity</th>
    </tr>

            <tr>
                <th>Apples</th>
                <td>$0.59/each</td>
                <td><input type="text" id="apples" size="2" /></td>
            </tr>
    
            <tr>
                <th>Oranges</th>
                <td>$0.49/each</td>
                <td><input type="text" id="oranges" size="2" /></td>
            </tr>
    
            <tr>
                <th>Bananas</th>
                <td>$0.39/each</td>
                <td><input type="text" id="bananas" size="2" /></td>
            </tr>
    
        </table>
    
        <!-- Button for retrieving the total -->
        <p>
            <input type="button" value="Total Cost" onclick="computeCost();" />
            <input type="text" size="5" id="cost" onfocus="this.blur();" />
        </p>
    
        <!-- Submit and reset buttons -->
    
    T 1 Reply Last reply
    0
    • T tristarterror

      Not sure what I'm missing here. When I click the Total Cost button nothing appears in the text input. I've looked over the documents for any syntax errors but I am just not finding it!! This is an assignment. I need to the total to be inside the input text box. I'm just looking for another set of eyes to see if I missed a semicolon or something simple somewhere. HTML:

      <!DOCTYPE html>
      <!--
      A document for exercise5-3.js

      Author: Trista Woods
      Date: 27 June 2013
      LOG:
      

      -->
      <html lang="en">
      <head>
      <title>Woods | Order Total | Execise 5.3</title>
      <meta charset="utf-8" />
      <script type="type/javascript" src="j/exercise5-3.js">
      </script>

      <!-- revert to external css -->
      <style type="text/css">
          td, th, table {border: thin solid black;}
      </style>
      

      </head>
      <body>
      <form action = "">
      <h3>Produce Order Form</h3>
      <!-- A bordered table for item orders -->
      <table>
      <tr>
      <th>Type of Produce</th>
      <th>Price</th>
      <th>Quantity</th>
      </tr>

              <tr>
                  <th>Apples</th>
                  <td>$0.59/each</td>
                  <td><input type="text" id="apples" size="2" /></td>
              </tr>
      
              <tr>
                  <th>Oranges</th>
                  <td>$0.49/each</td>
                  <td><input type="text" id="oranges" size="2" /></td>
              </tr>
      
              <tr>
                  <th>Bananas</th>
                  <td>$0.39/each</td>
                  <td><input type="text" id="bananas" size="2" /></td>
              </tr>
      
          </table>
      
          <!-- Button for retrieving the total -->
          <p>
              <input type="button" value="Total Cost" onclick="computeCost();" />
              <input type="text" size="5" id="cost" onfocus="this.blur();" />
          </p>
      
          <!-- Submit and reset buttons -->
      
      T Offline
      T Offline
      thanh_bkhn
      wrote on last edited by
      #2

      I think the problem is at your javascript declare statement. Wrong:

      <script type="type/javascript" src="j/exercise5-3.js">

      Right:

      <script type="text/javascript" src="j/exercise5-3.js">

      T 1 Reply Last reply
      0
      • T thanh_bkhn

        I think the problem is at your javascript declare statement. Wrong:

        <script type="type/javascript" src="j/exercise5-3.js">

        Right:

        <script type="text/javascript" src="j/exercise5-3.js">

        T Offline
        T Offline
        tristarterror
        wrote on last edited by
        #3

        That was it!! I knew it was something small!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups