Results 1 to 7 of 7

Thread: When press a button it loads page

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post When press a button it loads page

    Hi i am looking for a script that when a user press a number from 1 to 9 it loads a page.

    Like

    1 = index.php
    2 = about.php
    3 = contact.php

    so on so on.

    Thanks
    The web in one word.

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

    Default

    Code:
    <?php
    
    $pageID = $_REQUEST['pageID'] - 1;
    
    $files = array('index.php',
                      'contact.php',
                      'users.php',
                      'faq.php'
                      ); //notice no comma after last entry
    
    header('Location: '.$files[$pageID]);
    ?>
    Very simple, not tested and really sure if this is what you are looking for.
    In the files array, type in all of the pages in order by which you made your buttons.

    Hope this helps.
    "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

  3. #3
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    No i don't think this is what i need. what i mean it when they press the number 1 on there keyboard it loads the page.

    Like

    Num Pad 1 = index.php
    Num Pad 2 = about.php
    Num Pad 3 = contact.php
    The web in one word.

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

    Default

    That would be a javascript then. Not quite sure how you would do it, but I think you would have to do something like onkeyup or onkeydown with the key code that was pressed. You could probably google it, or something similar on here.
    "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

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

    Default

    Acually, heres a tutorial that tells you what is pressed and the code for it.

    http://www.javascriptkit.com/javatut...riptkey2.shtml
    "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

  6. #6
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok lets say i use this

    <script type="text/javascript">
    function textsizer(e){
    var evtobj=window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
    var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode
    var actualkey=String.fromCharCode(unicode)
    if (actualkey=="a")
    document.body.style.fontSize="120&#37;"
    if (actualkey=="z")
    document.body.style.fontSize="100%"
    }
    document.onkeypress=textsizer
    </script>

    is theer anyway to make it open a URL instead of reszing
    The web in one word.

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

    Default

    Change this:

    Code:
    document.body.style.fontSize="100&#37;"
    to this:

    Code:
    window.location = "index.php"
    change index.php to whatever you want.
    "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

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
  •