Click here to Skip to main content
15,903,175 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Load json data into data grid using javascript Pin
AlphaDeltaTheta12-Jul-13 23:11
AlphaDeltaTheta12-Jul-13 23:11 
QuestionDataTables - Multiple column sort with server side Pin
luefher3-Jul-13 19:42
luefher3-Jul-13 19:42 
AnswerRe: DataTables - Multiple column sort with server side Pin
Dennis E White4-Jul-13 9:22
professionalDennis E White4-Jul-13 9:22 
Questionsharing sessions between two web application with coherence Pin
elham emami2-Jul-13 3:09
elham emami2-Jul-13 3:09 
SuggestionRe: sharing sessions between two web application with coherence Pin
Aaron @ Think Software9-Jul-13 4:52
professionalAaron @ Think Software9-Jul-13 4:52 
GeneralRe: sharing sessions between two web application with coherence Pin
elham emami10-Jul-13 4:39
elham emami10-Jul-13 4:39 
QuestionHow can i double webcam capture and save "dim" in asp or vb? Pin
Uğur Şirin1-Jul-13 20:16
Uğur Şirin1-Jul-13 20:16 
QuestionCalculating a total from a form Pin
tristarterror1-Jul-13 13:34
tristarterror1-Jul-13 13:34 
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:
XML
<!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 -->
        <p>
            <input type="submit" value="Submit Order" />
            <input type="reset" value="Clear Order Form" />
        </p>

    </form>
</body>
</html>


JS File:
C#
// exercise5-3.js
// Computes a total charge for the order

// Author: Trista Woods
// Date: 27 June 2013

// The event handler function to compute the cost

function computeCost() {
    var apple = document.getElementById("apples").value;
    var orange = document.getElementById("oranges").value;
    var banana = document.getElementById("bananas").value;

    // Compute the cost
    document.getElementById("cost").value =
    totalCost = apple * 0.59 + orange * 0.49 + banana * 0.39;

}

AnswerRe: Calculating a total from a form Pin
thanh_bkhn1-Jul-13 15:34
professionalthanh_bkhn1-Jul-13 15:34 
GeneralRe: Calculating a total from a form Pin
tristarterror1-Jul-13 16:05
tristarterror1-Jul-13 16:05 
Questionhow to post webform asynchronously(with image upload) without using server side control Pin
Member 770211029-Jun-13 1:45
Member 770211029-Jun-13 1:45 
AnswerRe: how to post webform asynchronously(with image upload) without using server side control Pin
Dennis E White1-Jul-13 5:15
professionalDennis E White1-Jul-13 5:15 
Questionjava script Pin
noorh00727-Jun-13 7:24
noorh00727-Jun-13 7:24 
AnswerRe: java script Pin
Dennis E White27-Jun-13 7:38
professionalDennis E White27-Jun-13 7:38 
QuestionWhat do you think of this? Pin
Super Lloyd27-Jun-13 3:17
Super Lloyd27-Jun-13 3:17 
AnswerRe: What do you think of this? Pin
Dennis E White27-Jun-13 7:31
professionalDennis E White27-Jun-13 7:31 
GeneralRe: What do you think of this? Pin
Super Lloyd27-Jun-13 15:20
Super Lloyd27-Jun-13 15:20 
QuestionOnpage pagination is not working Pin
Md Shariful Islam Saful26-Jun-13 8:01
Md Shariful Islam Saful26-Jun-13 8:01 
AnswerRe: Onpage pagination is not working Pin
Dennis E White26-Jun-13 15:14
professionalDennis E White26-Jun-13 15:14 
QuestionUsing a switch statement to count variables in an array Pin
tristarterror24-Jun-13 11:09
tristarterror24-Jun-13 11:09 
AnswerRe: Using a switch statement to count variables in an array Pin
fixthebugg24-Jun-13 11:35
fixthebugg24-Jun-13 11:35 
AnswerRe: Using a switch statement to count variables in an array Pin
lmf232s24-Jun-13 12:07
lmf232s24-Jun-13 12:07 
AnswerRe: Using a switch statement to count variables in an array Pin
Manfred Rudolf Bihy24-Jun-13 20:06
professionalManfred Rudolf Bihy24-Jun-13 20:06 
QuestionVariables not showing correctly in HTML Pin
tristarterror24-Jun-13 9:17
tristarterror24-Jun-13 9:17 
AnswerRe: Variables not showing correctly in HTML Pin
dusty_dex24-Jun-13 9:45
dusty_dex24-Jun-13 9:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.