View Full Version : When press a button it loads page
queerfm
01-14-2007, 03:44 PM
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
thetestingsite
01-14-2007, 04:04 PM
<?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.
queerfm
01-14-2007, 04:59 PM
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
thetestingsite
01-14-2007, 05:19 PM
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.
thetestingsite
01-14-2007, 05:21 PM
Acually, heres a tutorial that tells you what is pressed and the code for it.
http://www.javascriptkit.com/javatutors/javascriptkey2.shtml
queerfm
01-14-2007, 06:31 PM
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%"
if (actualkey=="z")
document.body.style.fontSize="100%"
}
document.onkeypress=textsizer
</script>
is theer anyway to make it open a URL instead of reszing
thetestingsite
01-14-2007, 06:34 PM
Change this:
document.body.style.fontSize="100%"
to this:
window.location = "index.php"
change index.php to whatever you want.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.