Results 1 to 2 of 2

Thread: adding to a number

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

    Default adding to a number

    I'm using a small script that fetches a word from the location and displays it onto the page. I'm using numbers in this and I'm wondering if it is possible to modify the script so that it would write down the number from the location and then also a new number next to it, a number that is the original number + 1.

    Lets say that the location of the web is file.html?number=32.

    Then into the page would be written: 32_33

    Here is the script that I'm using:

    function numbers()
    {
    var paramValue;
    if( paramValue=window.location.search.match(/[?&]number=(\w+)/) )
    document.write( paramValue[1] );
    }
    Any ideas if this is possible and if so, how?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    <script type="text/javascript">
    ;(function(){ var num, gq = function(n) {
    var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=location.search;
    return (m=r.exec(m))? unescape(m[1]) : null;}; if(!isNaN((num=
    parseInt(gq('number')))))document.write(num++ + '_' + num);})();
    </script>
    </body>
    </html>
    Last edited by jscheuer1; 04-28-2008 at 06:39 PM. Reason: simplify and insulate code
    - John
    ________________________

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

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
  •