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
T

tristarterror

@tristarterror
About
Posts
5
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Calculating a total from a form
    T tristarterror

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

    JavaScript javascript html css tools architecture

  • Calculating a total from a form
    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 -->
    
    JavaScript javascript html css tools architecture

  • Using a switch statement to count variables in an array
    T tristarterror

    Another homework assignment so please just let me know what direction I should go in. Assignment details: Function: counter Parameter: An array of numbers Returns: The numbers of negative elements, zeros, and values greater than zero in the given array. Note: You must use a switch statement in the function. My JS file:

    // Array of Numbers

    var nums = new Array(-13,2,67,3,0,56,12,-41);
    var len = nums.length;

    for (i=0; i<len; i++) {
    var count = nums[i];
    }

    var count = nums[i];

    //Create counter function
    function counter() {

    switch (count) {
    case "negatives":
        if (count < 0) {
            document.write(count.length);
        }
        break;
    
    case "zeros":
        if (count == 0) {
            document.write(count.length);
        }
        break;
    
    case "positives":
        if (count > 0) {
            document.write(count.length);
        }
        break;
    
    default: {
        document.write("nothing!");
    }
    

    }};

    I am not sure where to go with this one. I know it's the switch statement that throwing me off and I am not sure if my statement for counting each variable is necessarily correct either but I feel like I'm somewhere in the correct thinking here.

    JavaScript javascript data-structures

  • Variables not showing correctly in HTML
    T tristarterror

    Oh geez! It's always the simple things that screw me up. I also noticed I was missing a semicolon after one of my statements too. Thanks for helping a beginner out!

    JavaScript javascript html tools help tutorial

  • Variables not showing correctly in HTML
    T tristarterror

    I am currently a college student so please be kind to me being a novice! I am working on an assignment and I just can't figure out where I am going wrong. Assignment Details: Function: tst_name Parameter: A string. Returns: true if the given string has the form String1, String2 letter where both strings must be all lowercase letter except for the first letter and letter must be uppercase; false otherwise My JavaScript file:

    function tst_name(name) {
    // simple pattenr to check the format of the name
    var ok = name.search(/^[A-Z][a-z]+, [A-Z][a-z]+, [A-Z]\.?$/);

    if (ok == 0) {
        return true;
    } else {
        return false;
    }
    

    } // end of function tst_name

    // Test function with two sets of data
    var tst = tst_name(Woods, Trista, M);
    if (tst) {
    document.write("Program error <br />");
    } else {
    document.write("Valid name. <br />");
    }

    var tst = tst_name(woods, trista, m);
    if (tst) {
    document.write("Invalid name <br />");
    } else {
    document.write("Program error <br />")
    }

    My HTML file:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
    <html lang="en">
    <head>
    <title>Woods | Test Name | Exercise 4.12</title>
    <script type="text/javascript" src="exercise4-12.js">
    </script>
    </head>
    <body>
    <script>
    document.write("Woods, Trista, M: " + tst + "<br />");
    document.write("woods, trista, m: " + tst + "<br />");
    </script>
    </body>
    </html>

    When I view this in a browser it just shows: Woods, Trista, M: undefined woods, trista, m: undefined So I'm just confused. I followed an example in our book and I just don't know what I need to do in order to get the variables to write the correct statements in my HTML document.

    JavaScript javascript html tools help tutorial
  • Login

  • Don't have an account? Register

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