Automatic Button 'Looping' for Navigation

This is a discussion on "Automatic Button 'Looping' for Navigation" within the JavaScript Forum section. This forum, and the thread "Automatic Button 'Looping' for Navigation are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 3rd, 2008, 15:29
New Member
Join Date: Apr 2008
Location: Armagh
Age: 22
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Automatic Button 'Looping' for Navigation

Hey guys, I was wondering if anyone would be so kind as to help me out

To put a long story short, i need a web site with a navigation devised from form buttons, which automatically tabs through each button in sequence every 1.5 or 2 seconds. This is to enable the user to simply hit enter when the sequence reaches their desired link (or button as it so happens). I have made a simple HTML page with what i thought had the basics working, but doesn't seem to. It does automatically choose button 1 onload.

Could anyone help me get this looping though these buttons?

if it started on 1, then 2, then 3 and back to 1 endlessly, that would be superb!

Thanks very much.



Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<script>
<!--
fuction pressTab(name)
{

		var elem = document.getElementById(name);
		elem.focus();
		return;
}
function init(name){
		setTimeout("pressTab('"+name+"')",1500);
		return;
}

function MM_goToURL() { //v3.0

	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}
</script>

</head>

<body onload="document.forms[0].box1.focus();">

<form name="forms">
  <label>
  <input type="button" name="box1" id="box1" 
  onFocus="init('box2');"
             onClick="MM_goToURL('parent','index.html'); return
             document.MM_returnValue" value="Home"
   />
  
  </label>
  <label>
  <input type="button" name="box2" id="box2"
  onFocus="init('box3');"
             onClick="MM_goToURL('parent','index.html'); return
             document.MM_returnValue" value="Home"
  />
  </label>
  <label>
  <input type="button" name="box3" id="box3"
  onFocus="init('box1');"
             onClick="MM_goToURL('parent','index.html'); return
             document.MM_returnValue" value="Home"
  />
  </label>
</form>
</body>
</html>
Reply With Quote

  #2 (permalink)  
Old Apr 3rd, 2008, 22:25
CloudedVision's Avatar
Nerdy Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 942
Blog Entries: 8
Thanks: 2
Thanked 22 Times in 22 Posts
Send a message via AIM to CloudedVision Send a message via MSN to CloudedVision Send a message via Skype™ to CloudedVision
Re: Automatic Button 'Looping' for Navigation

Quote:
To put a long story short, i need a web site with a navigation devised from form buttons, which automatically tabs through each button in sequence every 1.5 or 2 seconds.
May I ask why? I'm really curious why you would need to do this.

But first, get rid of the onfocus="javascript" things and the body onload. Then replace press_tab() with this:

Code: Select all
var focused = 0;
function press_tab() {
    focused++;
    if(focused==4)
        focused=1;
    document.getElementById('box'+focused).focus();
    setTimeout("press_tab()",1500);
}

window.onload = press_tab;
Give that a shot. I didn't try it out, so there will probably be a couple of errors.
__________________
echo "Take it easy, ".$CloudedVision;
.links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; }
<quote>&quot;I think it's wrong that only one company makes the game Monopoly&quot; - <name>Steven Wright</name></quote>
Last Blog Entry: More Cheat Sheets (Jul 12th, 2008)
Reply With Quote
  #3 (permalink)  
Old Apr 4th, 2008, 14:38
New Member
Join Date: Apr 2008
Location: Armagh
Age: 22
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Automatic Button 'Looping' for Navigation

Hey, thanks for the response CloudedVision.

Tried that out, it tabs through in the right sequence manually, but still not doing it automatically. hmmm.

Oh the reason i need it is to design a web site enabled for a neuromuscular disabled user, so that it tabs round the rings and only requires hitting enter, or, selection by brainwaves read from a BCI :0

I'm no good at javascripting unfortunatly :P

Could you take a look at this?

THANKS!

Code: Select all
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script>
<!--
var focused = 0;
function press_tab() {
    focused++;
    if(focused==4)
        focused=1;
    document.getElementById('box'+focused).focus();
    setTimeout("press_tab()",1500);
}
window.onload = press_tab;
function MM_goToURL() { //v3.0
 var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
 for (i=0; i<(args.length-1); i+=2) window[args[i]].location=args[i+1]);
}
</script>
</head>
<body>
<form name="forms">
  <label>
  <input type="button" name="box1" id="box1"
   />
  </label>
  <label>
  <input type="button" name="box2" id="box2"
  />
  </label>
  <label>
  <input type="button" name="box3" id="box3"
  />
  </label>
</form>
</body>
</html>
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Automatic Checkbox/Radio Button Checking Stuart JavaScript Forum 8 Nov 9th, 2007 01:55
Looping through arrays assgar Starting Out 1 Apr 22nd, 2007 18:43
PHP Looping script peterboy PHP Forum 3 Mar 10th, 2007 00:04
automatic pop-up when click on a radio button joshcxa JavaScript Forum 2 Aug 1st, 2006 06:06
looping background music gwx03 Flash & Multimedia Forum 6 Sep 7th, 2003 03:07


All times are GMT. The time now is 04:51.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43