Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 34
  1. #16
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by rnd me View Post
    i wouldn't be so sure if i were you. please check again, click run then the "rake leaves" button.

    i won't rub it in, but you should check these sort of things before posting, especially if i offer an easy out...
    Sorry, rnd me but I DO check thorougly before posting. Every time I run this script in IE9 the alert shows the text of the div/button.

    Note that

    <div>$1.00 <button value="1.00" onclick="bump(this.value)"> rake leaves/bag </button> </div>

    shows the text rake leaves/bag as the value of the button (the text contained in it) and not 1.00.

    If I change to <input type = "button" then the value of the button becomes 1.00 and that value passes to the alert. So I think that the fault is invalid HTML, not the Javascript.
    Last edited by Philip M; 04-26-2013 at 05:45 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  2. #17
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    Quote Originally Posted by Philip M View Post
    Sorry, rnd me but I DO check thorougly before posting. Every time I run this script in IE9 the alert shows the text of the div.
    IE9 huh? i didn't see that qualifier, only what appeared to a blatant error by a respected coder.

    Still, I tried it in IE9 and low and behold, i got "1.00".


    now, knowing you're not crazy, and that you're usually wise, i kept plugging at it and noticed that in IE9 quirks, indeed the innerHTML is swapped for the value. This actually makes some sense.

    I have to say that there's a big diff between IE9Quirks and IE9 Standard (the default), so please mention such parameters in future postings.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  3. #18
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by rnd me View Post
    IE9 huh? i didn't see that qualifier, only what appeared to a blatant error by a respected coder.

    Still, I tried it in IE9 and low and behold, i got "1.00".


    now, knowing you're not crazy, and that you're usually wise, i kept plugging at it and noticed that in IE9 quirks, indeed the innerHTML is swapped for the value. This actually makes some sense.

    I have to say that there's a big diff between IE9Quirks and IE9 Standard (the default), so please mention such parameters in future postings.
    Perhaps you might care to look at my remarks in post#6.

    <!DOCTYPE html> implies HTML5 which to me implies IE9.

    I don't see how swapping the innerHTML for the value makes any sense at all in any situation.

    Surely if HTML5 is mandatory it would have made sense for jmrker to place <!DOCTYPE html> at the start of his script. Without that surely the implication is that it works in HTML4.
    Last edited by Philip M; 04-26-2013 at 05:53 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  4. #19
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts

    Question

    Quote Originally Posted by rnd me View Post
    localStorage works in all browser since IE8, no compat concerns there. The file:// mode in IE, which js is not really meant for, is the only "exception" i know of. Many Many people block cookies using an add-on, and IE7 is < 1%, so it would not suprise me if localStorage is actually more reliable than cookies in the real world. A good litmus? Advertisers use it.


    I don't get the point about cookies: IE won't read chrome's cookies any better than it would its localStorage, no disadvantage there.
    considering the performance hits that cookies bestow, i avoid them by any means i can.
    One more (final???) question for my own understanding...

    I was not aware that I was using "The file:// mode in IE,..." as you discuss above.
    Are you saying that is a mode that occurs
    when I execute the HTML from a local file on my computer from any browser
    as opposed to having the script as a server file?

  5. #20
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts

    Unhappy

    Quote Originally Posted by Philip M View Post
    Perhaps you might care to look at my remarks in post#6.

    <!DOCTYPE html> implies HTML5 which to me implies IE9.

    I don't see how swapping the innerHTML for the value makes any sense at all in any situation.

    Surely if HTML5 is mandatory it would have made sense for jmrker to place <!DOCTYPE html> at the start of his script. Without that surely the implication is that it works in HTML4.
    I apologize for that. I did have the <!doctype html> on my version.
    Just missed copying that line onto the forum version. Lately I have been trying to include that line into all my new scripts.

  6. #21
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    Quote Originally Posted by jmrker View Post
    One more (final???) question for my own understanding...

    I was not aware that I was using "The file:// mode in IE,..." as you discuss above.
    Are you saying that is a mode that occurs
    when I execute the HTML from a local file on my computer from any browser
    as opposed to having the script as a server file?
    that's exactly what i'm saying. IE used to leave the door wide-open, you could ajax any domain, read and write files, write registry keys etc, then malicious FSO and activeX attacks started propagating on windows machines (shocking), and M$ took a lot of heat for it.

    so, ie over-compensated imho and locked everything down tight when a page is loaded from a file. Since a server implies a paper trail to a registered entity, they allow MORE freedom on http:// than file://.

    chrome and FF have always been fairly conservative with perms on file://s, but they too have batoned the hatches more and more as time goes on. you used to be able to ajax local files from any folder on the drive in FF, then it was sub-dir files only, then they stopped even letting you list sub-folders, so you have to know the exact path of a file to ajax it.

    anyway, yeah, there's a big diff between http, file, blob, data, and https page origins.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  7. #22
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    I'm just a little curious why anyone with a Windows machine *WOULD* use file:// access.

    At least anyone with any version of Windows other than the "Home Basic" version.

    Even with "Home Premium" (or "Home Extended" or whatever the name is for a given Windows version) in Windows XP, Windows Vista, Windows 7, and Windows 8 (and even Win95 and Win98 if anybody cares), you *DO* have IIS available to you and it's trivial to set up and then use.

    Granted, the basic version of IIS has some limitations. For example, you are only allowed one "domain" where you can support multiple domains on any Windows Server version. But those limitations have only given me problems maybe once or twice a year.

    So I haven't ever used "file://" except occasionally to test out assertions in this forum that it doesn't work (and it doesn't).

    And in any case, if you ever want to publish code to a real server, testing it first in IIS on your home machine makes lots of sense.

    If you *ARE* stuck with the most basic version of Windows, it's really not much cost to upgrade it. And most PCs nowadays come with either Win7 or Win8 Home Premium edition either free or for a nominal upgrade cost.

    Last but not least, if you do install IIS on your home machine, then you can also develop ASP.NET applications or PHP applications. Yes, IIS 7 supports PHP.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  8. #23
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts
    @Old Pedant:

    What does IIS stand for in your last post?

  9. #24
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,650
    Thanks
    80
    Thanked 4,636 Times in 4,598 Posts
    Internet Information Services. That's Microsoft's universal web server. It's what all Windows-based systems run for a web server (well, you can load Apache onto Windows...but IIS is the default). It comes in slightly different "flavors", depending on what version of Windows you are using. As I mentioned, on Home Premium it only supports a single web site, whereas on Windows Server (even Windows Small Business Server) it will support dozens or more web sites. I know one system I work on with Small Business Server supports 22 different IP Addresses, for example (more than that number of web sites, because [for example] we have both ".com" and ".net" pointed to the same IP address for all).
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  10. #25
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts
    I guess 'chads' lost interest as he/she has not posted back since original question.

  11. #26
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by jmrker View Post
    I guess 'chads' lost interest as he/she has not posted back since original question.
    Yeah, I think we have managed to frighten him away.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  12. #27
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi,

    No I have not been frightened away. It is just taking me a long time to learn some of these things. Thank you for you ideas Jmrker. I am slowly adapting them to what I need.

    All the other talk has completely lost me

    It is not a homework project, we don;t even do any type of programming at school yet. My IT teacher is my Science teacher and she doesn't know that much more than me.

    Thank you all for your help.

  13. #28
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts

    Thumbs up

    OK, glad we could help so far.

    Suggestions:
    1. Keep asking questions until the answers start to become familiar.
    2. Create small scripts to begin and test them until you find no further errors.
    3. Follow other threads on this (and other) forums looking for concepts you can incorporate into your own programs.
    4. Try to modularize or functionalize as much as possible so you can re-use code at a later time.

    Good Luck!

  14. Users who have thanked jmrker for this post:

    chads (05-16-2013)

  15. #29
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,146
    Thanks
    39
    Thanked 505 Times in 499 Posts

    Question

    You have a number of syntax errors in the HTML, like multiple <body> tags, mis-matched <td> </td> pairs
    and an orphaned '<' character.

    Click and Click1 are not really helping me understand the function.
    Are they to be a total count of the number of times any item in the list on the left is clicked?
    Or is the "clicked" count supposed to be for each item on the left?

    Fix the HTML and then restate the problem associated with the linkedClick function you have added.

  16. Users who have thanked jmrker for this post:

    chads (05-18-2013)

  17. #30
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <head>
    <title>Pocket Money</title>
    <meta http-equiv="Content-Type" content=
    "text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width">
    <meta name="viewport" content=
    "initial-scale=1.0, user-scalable=yes">
    <style type="text/css">
    @media screen { body { font-size: 16px } }
    @media screen, print { body { line-height: 1.2 } }
    div { width:300px; float:left; }
     p { clear:both; }
    </style>
    <!-- Modified for: http://www.codingforums.com/showthread.php?p=1331197#post1331197 -->
    </head>
    <body>
    <form id="myform" method="post" onsubmit="return false"
    name="myform">
    <div style=" text-align: centre; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;"> <table width="100%" border="0" cellpadding="2" cellspacing="10" style="background-color: #045FB4;">
    <tr valign="top">
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.50" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.50" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.50" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.50" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="1.00" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-1.00" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.25" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.25" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.50" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.50" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.25" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.25" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.10" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.10" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.10" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.10" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="1.00" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-1.00" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="0.25" onclick="bump(this.value);linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-0.25" onclick="bump(this.value); linkClick();"><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="1.50" onclick="bump(this.value); linkClick()"><br>
    <td style="border-width : 0px;"><INPUT type="image" src="" value="-1.50"  onclick="bump(this.value); linkClick(); "><br>
    <td style="border-width : 0px;"><input id="clicked" size="3"  value="0">
    </tr>
    <tr>
    <td style="border-width : 10px;">
    <td style="border-width : 0px;"><input type="text" width: 100px; height: 100px; readonly id="totaljobs" value="0" input style="width:60px; height:30px;font-size:18pt;color:black; border-style:12 ;weight:bold ; background-color: #CED8F6;">
    <button onclick="clearTally()">Clear</button> 
    </tr>
    </table>
    </div>
    <script type=
    "text/javascript">
      function bump(jobs) {
        var total = Number(document.getElementById('totaljobs').value);
        total += Number(jobs);
        document.getElementById('totaljobs').value = total.toFixed(2);
        persistTally();
      }
      function clearTally() {
        document.getElementById('totaljobs').value = '0.00';
        persistTally();
      }
    var clicks = 0;
    function linkClick(){
        document.getElementById('clicked').value = ++clicks;
    
    }
    /* * Indicate if this browser supports local storage.  */
      function html5StorageSupported() {
         return ('localStorage' in window) && window['localStorage'] !== null;
      }
    
    /* * Provide indication on web page of whether this browser supports local storage.  */
      function initializeTally() {
        if ( html5StorageSupported() ) {
          if (localStorage['tally.total'] == undefined) { clearTally(); } else { loadTally(); }   // altered original code here
        } else { alert('Local storage is not supported'); }
      }
    
    /* * Save tally total to local storage.  */
      function persistTally() {
         if (html5StorageSupported()) { 
           var tally = document.getElementById("totaljobs").value;
           var storageIndex = "tally.total";
           localStorage[storageIndex] = tally;
         } else { alert("Cannot save to local storage because it's not supported."); }
      }
    
    /* * Load tally total from local storage.  */
      function loadTally() {
         if (html5StorageSupported()) {
           document.getElementById('totaljobs').value = localStorage["tally.total"];
         } else { alert("Cannot load from local storage because it's not supported."); }
      }
    
    window.onload = function() { initializeTally(); }
    
    </script></form>
    </body>
    </html>
    Hi Jmrker,

    hopefully that is a bit better?

    I am trying to get a tally of the number of times I have done a job in the text box on the far right. I have included the command in onclick, so that when it is clicked it tallys up the number of times I have done that job, and also adds up to the dollar amounts in the box underneath. This is so I can keep a separate tally for each job.

    The problem is I can't separate the jobs with the funtion. I'm sorry, I don't know how to describe this properly.


 
Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •