HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 28th, 2000, 09:24 AM
Troy Paulson Troy Paulson is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 1 Troy Paulson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have a page with two submit buttons. Is there a way to use the focus() function to place focus on the second button instead of the first (default)? Here are what the tags look like:

<INPUT TYPE="SUBMIT" VALUE="Previous" NAME="BUTTON">
<INPUT TYPE="SUBMIT" VALUE="Continue" NAME="BUTTON">

The Name of the buttons need to be the same (this is in CGI program I'm writing to create this page. I check to see which button is pressed by the value.). I've tried the following in the Body onload event:

document.forms[0].BUTTON[1].focus()

but it didn't seem to work.

Thanks for any help you can give.

Troy

Reply With Quote
  #2  
Old July 9th, 2000, 12:23 AM
rkmarcks rkmarcks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 81 rkmarcks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via AIM to rkmarcks
I don't think the problem is your statement, but rather how you named your buttons. The name simply gives the button a label. It is not an array variable which is how you're trying to use it in your JS statement. Simply name each button uniquely, ie:button1 and button2. Then rewrite your JS statement to say:

document.forms[0].button2.focus()

you could also use:

document.forms[0].element[x].focus()

where 'x' is the array number of the button element. Since an element is anything, ie: link,button, checkbox, etc., you would determine the number of the element by counting (from 0) the location within your source code, not where it appears on the page. But I find this more confusing than using a name.

Russ

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Place focus on input type submit


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway