Results 1 to 5 of 5

Thread: Javascript Button Links

  1. #1
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript Button Links

    I came across a javascript that can act as a 'phone' about 7 or 8 years ago. You sort of assign numbers to links .. i.e 017 or 999. Then on the webpage, there will be 10 buttons 0-9 and you can press a combination of numbers (i.e. press 9 three times) and it will take you to the website assigned to that combination.

    Any idea where I can find such a script or similar? Thank you ^_^

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Does this help you?
    HTML Code:
    <html>
    <head>
    <title>KeyPad Combination</title>
    </head>
    <body onLoad="generateKeypad(false)">
    <script type="text/javascript">
    var combination = "";
    var disabled = "";
    var innerR = "";
    function includeNum(self){
    combination += self.value;
    if(combination.length == 3){
    disabled="disabled";
    generateKeypad(true);
    switch(combination)
    {
    case "123":
    window.location="http://google.com";
    break;    
    case "890":
    window.location="http://dynamicdrive.com";
    break;
    default:
    window.location="http://yahoo.com";
    }
    }
    }
    function generateKeypad(){
    innerR = "";
    for(i=1;i<=3;i++){
    innerR += '<button onClick="includeNum(this)" value="'+i+'" '+disabled+'>'+i+'</button>';
    }
    innerR += '<br />';
    for(i=4;i<=6;i++){
    innerR += '<button onClick="includeNum(this)" value="'+i+'" '+disabled+'>'+i+'</button>';
    }
    innerR += '<br />';
    for(i=7;i<=9;i++){
    innerR += '<button onClick="includeNum(this)" value="'+i+'" '+disabled+'>'+i+'</button>';
    }
    innerR += '<br /><button onClick="includeNum(this)" value="0" '+disabled+'>0</button>';
    document.getElementById('keypad').innerHTML=innerR;
    }
    </script>
    <div id="keypad">null</div>
    </body>
    </html>
    I think that there are 3486784401 possible combinations. To add a new combination, before:
    Code:
    default:
    window.location="http://yahoo.com";
    Add:
    Code:
    case "digit":
    window.location="website.com";
    break;
    Replace the red with the three digit number, and the blue with the site. To change the ones that I already put in, I think you can figure out by what I gave you above. If you can't. Just post.
    Last edited by Nile; 06-10-2008 at 03:00 AM. Reason: yellow to light; switched to red
    Jeremy | jfein.net

  3. #3
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    <333!!!!
    thank you so much!!! you are such a star <33

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Anytime, just took around 5 - 10 minutes.
    Jeremy | jfein.net

  5. #5
    Join Date
    Dec 2008
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Fantastic piece of coding, thanks for sharing. I'm a bit of a novice at this and am trying to use your code to do something slightly different.....what i'm trying to do is to create on screen ‘hotspots’ which will be invisible, and the location only known to the administrators. Once the correct sequence has been pressed the code will call up a specified url. My first thought was to make the keypad buttons bigger and somehow invisible….but it’s beyond my basic knowledge.

    Can anybody help please

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
  •