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.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Printing the last 4 digits when using getParams

    I am trying to figure out how to print the last 4 digits instad of the whole thing when the page prints the paramiters, or params, whatever... Heres the script:


    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    <!-- Begin
    function getParams() {
    var idx = document.URL.indexOf('?');
    var params = new Array();
    if (idx != -1) {
    var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
    for (var i=0; i<pairs.length; i++) {
    nameVal = pairs[i].split('=');
    params[nameVal[0]] = nameVal[1];
       }
    }
    return params;
    }
    params = getParams();
    //  End -->
    </script>
    
    
    
    <SCRIPT LANGUAGE="JavaScript">
    quantity = unescape(params["ordernumber"]);
    document.write(ordernumber);
    </SCRIPT>

    Any comments or suggestions would greatly be apreciated. Thanks.


    ~Isaac Lloyd~
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following

    <script language="javascript">
    <!--
    dataPassed=0

    if (location.search.length > 0){
    url = unescape(location.search.substring(1))

    str=url.substring(url.length-4,url.length)

    alert(str)
    }

    // -->
    </script>
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New Coder
    Join Date
    Dec 2002
    Location
    Washington State
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    *EDIT* NM, I figured it out. Thanks for your time.


    in which par of my script would I put that? and what is that printing out? the whoe URL? See I have a lot more Params that I don't want to show only 4 digits. Example:

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    quantity = unescape(params["firstname"]);
    document.write(firstname);
    
    quantity = unescape(params["lastname"]);
    document.write(lastname);
    
    quantity = unescape(params["creditcardnumber"]);
    document.write(creditcardnumber);   <--- This one show only the last 4 digits.
    
    
    </SCRIPT>
    Thanks for your time and help.

    ~Isaac Lloyd~
    Last edited by isaaclloyd; 03-26-2005 at 11:53 PM.
    ~ Isaac Lloyd ~
    Website Design & Development
    http://www.IsaacLloyd.com

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    quantity = unescape(params["creditcardnumber"]);
    quantityA = quantity.substring(quantity.length-4,quantity.length);
    quantityA="XXXX XXXX XXXX " + quantityA;
    document.write(quantityA); <--- This one show only the last 4 digits.


  •  

    Posting Permissions

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