SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Incrementing not working for me???

    I am trying to increment 707185109 to the amount of pages that are in a mysql database. However that isn't working for me. So can someone please help me out here? Thanks in advance.

    Here is the code that I am working with:
    Code JavaScript:
    // get the total amount of pages
    var b = <?php echo $total_pages; ?>;
    // place menu number into a variable
    var num = 707185109;
    for (var i = num; i < b; i++) {
    	var c = document.write(_0 + i + _0);
    }

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Looks like your adding a number to a string
    Code:
    var c = document.write("_0" + i +" _0");
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have made the changes to my code Markdidj and the incrementing still isn't showing.

  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    c=("_0" + i +"_0")

    but then c will always equal the last number of the loop.

    I don't uderstand what the loop is trying to do, but maybe use

    document.write ("_0" + i + "_0");

    or document.write("c='_0" + i + "_0'");
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  5. #5
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you able to tell me a better way of doing this please, then?

  6. #6
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry, haven't been on for a while, so if you haven't worked it out
    Code:
    // get the total amount of pages var b = <?php echo $total_pages; ?>; // place menu number into a variable var num = 707185109; for (var i = num; i < b; i++) { var c = "_0" + i +" _0"; }

    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •