473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Setting focus on radio button

Hi All:

I would like to know how to set the focus on a radio button (if it is
possible)

I tried button[0].focus() but with no luck

The reason that I need to do this is to validate a form. If the user does
not select a radio button I would like my validation code to set the focus
at the first radio button within the pair that was not selected that way
he/she does not have to look for it.

Thanks in advance
Terry
Jul 20 '05 #1
3 28176
In article <ny*******************@news04.bloor.is.net.cable.r ogers.com>,
tg******@rogers.com enlightened us with...
Hi All:

I would like to know how to set the focus on a radio button (if it is
possible)

I tried button[0].focus() but with no luck


document.formname.elements["radioname"][index].focus();

Radios are an array because they all have the same name.
The index goes from 0-(length -1).

-------------------------------------------------
~kaeli~
All I ask for is the chance to prove that money
cannot make me happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #2
Thanks kaeli it seemed to work. Although the focus was only brought close
to the button. Actually the button did not really receive the focus.
Instead what happened was that the form was scrolled to an area that
contained the radio button.

Terry

"kaeli" <in********************@NOSPAMatt.net> wrote in message
news:MP************************@nntp.lucent.com...
In article <ny*******************@news04.bloor.is.net.cable.r ogers.com>,
tg******@rogers.com enlightened us with...
Hi All:

I would like to know how to set the focus on a radio button (if it is
possible)

I tried button[0].focus() but with no luck


document.formname.elements["radioname"][index].focus();

Radios are an array because they all have the same name.
The index goes from 0-(length -1).

-------------------------------------------------
~kaeli~
All I ask for is the chance to prove that money
cannot make me happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------

Jul 20 '05 #3
In article <vh*******************@news04.bloor.is.net.cable.r ogers.com>,
tg******@rogers.com enlightened us with...
Thanks kaeli it seemed to work. Although the focus was only brought close
to the button. Actually the button did not really receive the focus.
Instead what happened was that the form was scrolled to an area that
contained the radio button.


That is the expected behavior from what I understand. Otherwise, it
would be a click and would select it. Instead, it focuses on the radio
group (object) containing that element.

If someone knows otherwise, please correct me.

-------------------------------------------------
~kaeli~
All I ask for is the chance to prove that money
cannot make me happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Muralidhar | last post by:
Hi, I'm having a jsp page which is having a table and a div tag.The heading such as a radio button,Name , Age etc. are fixed.Only the data under it is scrolling. So i've set one table for header...
2
by: Mike Irwin | last post by:
I'd like to prevent a submit button from getting focus unless a particular textbox or radio button is selected. For example, if a user clicks anywhere within a form, the submit button is focused...
2
by: Paul Thompson | last post by:
I am trying to use various javascript tools, all of which work in NN, to work in IE. Here's my latest annoyance. I get a list of all objects on a page using docContents =...
1
by: Jim Quast | last post by:
I have an ASP page and a CREGReports002.vbs file coded to export data to excel. I do this by building variables in a stored procedure. The ASP page has text boxes, list boxes, and radio buttons. ...
1
by: Anthony | last post by:
Hi, Is there a way to put focus on a form element of type radio or checkbox. It only seems to work on input of type text... Thanks in advance, Anthony
3
by: MarsVoyager | last post by:
Hi, I want to change the value of a submit button when the onChange event is fired by a Radio Input. Problem is, it seems the value is modified in the gui only when the Radio Input looses focus,...
16
by: Stuart | last post by:
I have a page where I utilise the left and right cursor keys to change an image, also on this page is a groups of radio buttons, unfortunately when a radio button is clicked the focus for the...
1
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
7
by: IchBin | last post by:
I am trying to programmatically set a radio button in a table of radio buttons. I have two problems with the code below: 1 - I can not prepare the <Formstatement to be printed by php. (syntax...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.