Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Multiple instances - how?

  1. #1
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Multiple instances - how?

    1) Script Title: Dynamic Countup script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...countingup.htm

    3) Describe problem:

    The listing for this script says it is possible to have multiplt instances of this sript running using, but just how do you do it? My meagre JS skills hit the brickwall of lack of knowledge when I try, thanks for your help.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    dcountup(startingdate, baseunit);
    where starting date is in format (month day, year hour:minute:second)
    --where hours are military time
    --eg 1pm = 13 2pm = 14 ... 11pm = 23 12am(minight) = 00

    and baseunit = (days, hours,minutes or seconds) written out

    then you need to initialize it to say what you want so you edit this inside your <head> js custom script
    Code:
    princewedding.oncountup=function(result){
      var mycountainer=document.getElementById("cpcontainer")
      mycountainer.innerHTML="message_to_display"+ result['days']+" days "+result['hours']+" hours "+result['minutes']+" minutes "+result['seconds']+" seconds"
    }

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,030
    Thanks
    44
    Thanked 3,211 Times in 3,173 Posts
    Blog Entries
    12

    Default

    boogyman,

    That doesn't look like what it says to do on the demo page. Did you test it out?

    Once you've put Step 1 from the demo page in the head of your page, it says that you can have as many of these in the body as you like:

    Code:
    <div id="cpcontainer">&nbsp;</div>
    
    <script type="text/javascript">
    
    //SYNTAX: myvariable=new dcountup(past_date_and_time_string, "baseunit")
    var princewedding=new dcountup("April 9, 2005 13:30:00", "days")
    
    princewedding.oncountup=function(result){
    	//result is an object containing the current count up date/time, updated every second
    	//Available properties: result["days"], result["hours"], result["minutes"], and result["seconds"]
    	var mycountainer=document.getElementById("cpcontainer")
    	mycountainer.innerHTML="Prince Charles and Camilla Parker have been married for: <br /><span class='dcountstyle'>"+result['days']+" <sup>days</sup> "+result['hours']+" <sup>hours</sup> "+result['minutes']+" <sup>minutes</sup> "+result['seconds']+" <sup>seconds</sup></span>"
    }
    
    </script>
    Color codes:

    Black - The parts of the code that must remain unchanged.

    Green - These are just comments that tell you what you can do.

    Blue - These are things that you will customize as you see fit.

    Dark Red - These are the id of the container for the output. Each instance needs one and only one of these but, it must be unique to that instance and used in the two places shown.

    Red - These are the variable name that identifies the instance. This also must be unique to the instance and used in the two places shown.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John

    I really appreciate the time taken to reply.

    Unfortunately I'm slightly color blind and I'm having some slight difficulty distinguishing between the dark red and black bits in your code clip. Would you mind awfully, changing the dark red bits to another colour perhaps a lurid purple, or something equally hideous!

    Sorry to be a pain,
    thanks
    a

  5. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    boogyman,

    That doesn't look like what it says to do on the demo page. Did you test it out?

    Once you've put Step 1 from the demo page in the head of your page, it says that you can have as many of these in the body as you like:

    Code:
    <div id="cpcontainer">&nbsp;</div>
    
    <script type="text/javascript">
    
    //SYNTAX: myvariable=new dcountup(past_date_and_time_string, "baseunit")
    var princewedding=new dcountup("April 9, 2005 13:30:00", "days")
    
    princewedding.oncountup=function(result){
    	//result is an object containing the current count up date/time, updated every second
    	//Available properties: result["days"], result["hours"], result["minutes"], and result["seconds"]
    	var mycountainer=document.getElementById("cpcontainer")
    	mycountainer.innerHTML="Prince Charles and Camilla Parker have been married for: <br /><span class='dcountstyle'>"+result['days']+" <sup>days</sup> "+result['hours']+" <sup>hours</sup> "+result['minutes']+" <sup>minutes</sup> "+result['seconds']+" <sup>seconds</sup></span>"
    }
    
    </script>
    Color codes:

    Black - The parts of the code that must remain unchanged.

    Green - These are just comments that tell you what you can do.

    Blue - These are things that you will customize as you see fit.

    Dark Red (Magenta) - These are the id of the container for the output. Each instance needs one and only one of these but, it must be unique to that instance and used in the two places shown.

    Red - These are the variable name that identifies the instance. This also must be unique to the instance and used in the two places shown.

    dark red changed to magenta (pink)

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    And so, the prophecy has been fulfilled.

    On a more serious note, this could become a real problem. Can anyone think of a better way to highlight code than using colour?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    I have tried used colors, bold, italics (but that was hard to read the code), and even made the size of the text larger. Usually though, the best way (I find) is to use colors.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    how about underline / overline / ____ ? or a format could be developed for this purpose? i dunno maybe with "code" boxes around it or something?? I dunno just a thought

  9. #9
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What have I started!

    One way I use is to use a comment line (or lines) underneath
    //Change this ------------^^^^^
    //Dont change this --------------------^^^^^

    It requires careful planning to avoid overlap and can look messy but when changed, the code can be tidied up and extraneous comments removed. Careful choice of non-proportional fonts would be needed.

    I doubt that there is a perfect way for everybody but thats accessibility

    Any other suggestions?

  10. #10
    Join Date
    Jun 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Tried multiple pastes to no avail

    1) Script Title: Dynamic Countup Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...countingup.htm

    3) Describe problem:

    I want to have multiple countup calculaters running on my page, its for a quit smoking website goingcoldturkey.com, where I want more than one person to pledge a quitting date.

    I tried pasting the body part mulitple times, but only get some type of error NAN in the timer fields, and then will rotate to the next entry. I would like to have all entries one under another.

    Can this actually be done?

    Thanks

Bookmarks

Posting Permissions

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