JMRKER's Profile User Rating: -----

Reputation: 128 Stalwart
Group:
Active Members
Active Posts:
826 (0.39 per day)
Joined:
25-October 08
Profile Views:
8,925
Last Active:
User is offline Yesterday, 06:29 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Who Cares
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   JMRKER has not set their status

Posts I've Made

  1. In Topic: Recalling results from simple calculations

    Posted 16 Jul 2014

    Your second code script of post #5 has errors.

    You cannot use '&' as part of an HTML or JS variable name. Invalid syntax.

    Also, you are continuing to use document.write,
    which as I said before will reset your program
    and will cause the very same problems you are reporting now.
    Note my prior code example and get rid of them.

    Or use .innerHTML instead.

    :whistling:/>
  2. In Topic: Recalling results from simple calculations

    Posted 14 Jul 2014

    The major problem you have with your code is the use of document.write.
    If any of these lines are executed after the page is rendered,
    all information is reset to the original conditions and all information is lost.

    Trying to keep a majority of your assumed homework code, you will need to make
    changes similar to the following. Note: there are other ways to accomplish the task.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=UTF-8" />
    <title>Week3 Assignment</title>
    <meta charset="UTF-8" />
    </head>
    
    <body>
    <div id="debug">Can be removed after testing</div>
    
    <form id="form1" name="form1" method="post" action="" onsubmit="return CalculateMPG()">
      <p align="center">&nbsp;</p>
      <p align="center" class="style1">Calculate Your Miles Per Gallon</p>
      <p align="center" class="style3">Miles Driven: 
        <label>
        <input type="text" id="miles" value="" />
        </label>
      </p>
      <p align="center" class="style3">Gallons of Gas Used: 
        <label>
        <input type="text" id="gallons" value="" />
        </label>
      </p>
      <p align="center" class="style3">Price per gallon: 
        <label>
        <input type="text"id="pricepergallon" value="" />
        </label>
      </p>
      <p align="center" class="style2"><span class="style4">Miles Per Gallon:</span> 
        <label>
        <input type="text" id="mpg" readonly />
        </label>
      </p>
      <p align="center" class="style2">
        <label>Calculate MPG
        <input type="submit" id="Calculate" value="Submit" />
        </label>
      </p>
      <p align="center" class="style2">
        <label>Clear Form
        <input type="button" onclick="location.reload(true)" value="Clear" />
        </label>
      </p>
      <p>&nbsp;</p>
    </form>
    
         <script>
    function CalculateMPG() {
    	 var miles = document.getElementById('miles').value;
    	 miles = parseFloat(miles);
    //         document.getElementById('debug').innerHTML = "The number of miles driven is " + miles + "." + "<br>";
    	 
    	 var gallons = document.getElementById('gallons').value;
    	 gallons = parseFloat(gallons);
    //         document.getElementById('debug').innerHTML += "The gallons of gas used is " + gallons + "." + "<br>";
             
             var priceGallon =document.getElementById('pricepergallon').value;
             priceGallon = parseFloat(priceGallon);
    //         document.getElementById('debug').innerHTML += "The price of a gallon of gas is $" + priceGallon + "." + "<br>";
    	 
    	 var mpg = miles / gallons;
    	 mpg = parseInt(mpg);
    //         document.getElementById('debug').innerHTML += "The miles per gallon is " + mpg + "." + "<br>";
             
             var costTrip = miles/priceGallon;
             costTrip = parseFloat(costTrip);
    //         document.getElementById('debug').innerHTML += "The cost of the trip is $" + costTrip.toFixed(2) + "." + "<br>";
             
             //alert("The MPG is " + mpg);
             //alert("The trip cost is " + costTrip.toFixed(2));
             document.getElementById('mpg').value = mpg.toFixed(2);
    
             //$("mpg").firstChild.nodeValue = ("The MPG is: " + mpg); 
             //document.getElementById().firstChild.nodeValue; 
             //var mpg = miles / gallons;
             //<p id= "mpg"></p>;
             //<p>The MPG is: <span id="mpg"></span></p>;
      return false;
    }    
         </script>
    </body>
    </html>
    
    
    


    Notes,
    1. you will need to add logic for your cost per trip calculations as I removed it in this version.
    2. you should put your script code just before the </body> tag as shown.
  3. In Topic: Your Opinion On The Best Language For Beginners

    Posted 14 Jun 2014

    For the absolute beginner to learn programming concepts
    and get immediate feedback,
    it's hard to beat "Logo", if you can find it.
  4. In Topic: Image Change Based on Day/Time

    Posted 6 Jun 2014

    My guess to the solution to your problem.

    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Logo Script </title>
    </head>
    <body>
    <img id="personality" src="" alt="">
    
    <script type="text/javascript">
    // For: http://www.dreamincode.net/forums/topic/348197-image-change-based-on-daytime/
    
    /*
    var baseURL = '';
    var logos = [
        	'/images/shows/Show1.png', 
        	'/images/shows/Show2.png',
    	'/images/shows/Show3.png',
     	'/images/shows/Show4.png',
    	'/images/shows/Show5.png',
    	'/images/shows/Show6.png',
    	'/images/shows/Show7.png',
    	'/images/shows/Show8.png'
    ]; 
    */
    var baseURL = 'http://www.nova.edu/hpd/otm/pics/4fun/';
    var logos = [
       '11.jpg',  // default image for "No shows on Sunday"
       '12.jpg',  // Hour range image for 11pm to 1am
       '13.jpg',  //   range for 1am to 6am
       '14.jpg',  //   range for 6am to 12pm
      ' 15.jpg',  //   range for 12pm to 3pm
       '21.jpg',  //   range for 3pm to 4pm
       '22.jpg',  //   range for 4pm to 5am
       '23.jpg',  //   range for 5pm to 6am
       '24.jpg',  //   range for 4pm to 5am
       '25.jpg',  //   range for 4pm to 5am
       '12.jpg'   //   range for 11pm to 1am
    ];
    
    function HourRange(hh) {
      if (hh < 1)  { return 1; }  // to 1am
      if (hh < 6)  { return 2; }  // to 6am
      if (hh < 12) { return 3; }  // to noon
      if (hh < 15) { return 4; }  // to 3pm
      if (hh < 16) { return 5; }  // to 4pm
      if (hh < 17) { return 6; }  // to 5pm
      if (hh < 20) { return 7; }  // to 8pm
      if (hh < 21) { return 8; }  // to 9pm
      if (hh < 22) { return 9; }  // to 10pm
      if (hh > 21) { return 1; }  // to midnight
      return 0;  // should never get here // alert('Error in hour passed');
    }
    function personalityDisplay() {
      var now = new Date();
      var DOW = now.getDay();
      var HH = now.getHours();
      var pic = HourRange(HH);
    
      switch (DOW) {
        case 1: case 2: case 3: case 4: case 5: break; // Monday through Friday logic
        case 6: pic = 0;  break;                       // Saturday logic
        default: pic = 0;  break;                      // Sunday logic - No Shows (???)
      }
      document.getElementById('personality').src = baseURL + logos[pic];
      document.getElementById('personality').alt = baseURL + logos[pic];
    }
    
    onload = function () { personalityDisplay(); }
    
    </script>
    </body>
    </html>
    
    
    


    NOTE:
    1. Alter 'baseURL' to match your domain and path

    2. Use your filenames for the personality to display.
    I used some goofy ones for testing.
    I reserved a space for 'No personalities', like on a Sunday.

    3. If hours change on the individual days,
    rather than being the same for Mon-Fri, a bit more mods are needed.
    Your original post did not go into enough complete detail.
  5. In Topic: Titanium Studio: Count up on click

    Posted 30 May 2014

    Consider this (without label)...
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> HTML5 page </title>
    
    </head>
    <body>
    <button id="btn" onclick="incCount(this.innerHTML)" style="font-size:3em;background-color:lime"> 0 </button>
    <script type="text/javascript">
    function incCount(cnt) { document.getElementById('btn').innerHTML=Number(cnt)+1; }
    </script>
    </body>
    </html>
    
    

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Florida
Programming Languages:
javascript, perl, java, forth, basic, fortran, assembly (several)

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Comments

JMRKER has no profile comments yet. Why not say hello?