Capturing Keys to Select Radio Buttons 
Author Message
 Capturing Keys to Select Radio Buttons

I'm totally new to JavaScript (I'm normally an ASP/SQL guy), but I
have a need to select a radio button based on keyboard input.  

For example, I have three choices for the radio group A, B, and C.  I
want the user to simply press A, B, or C on the keyboard instead of
having to click the choice.  Any sample code would be appreciated.

corbin



Wed, 18 Dec 2002 03:00:00 GMT  
 Capturing Keys to Select Radio Buttons

<html>
<head>
<script>
function go() {
if(window.event.keyCode=="65"||window.event.keyCode=="97")
one(0).checked=true;
if(window.event.keyCode=="66"||window.event.keyCode=="98")
one(1).checked=true;
if(window.event.keyCode=="67"||window.event.keyCode=="99")
one(2).checked=true;

Quote:
}

</script>
</head>
<body onkeypress=go()>
<input type=radio name=one>a<p>
<input type=radio name=one>b<p>
<input type=radio name=one>c
</body>
</html>
--
Mark L. Ferguson    Please reply in Newsgroup
marfer's notes for OE 5 > http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm
Quote:

> I'm totally new to JavaScript (I'm normally an ASP/SQL guy), but I
> have a need to select a radio button based on keyboard input.  

> For example, I have three choices for the radio group A, B, and C.  I
> want the user to simply press A, B, or C on the keyboard instead of
> having to click the choice.  Any sample code would be appreciated.

> corbin

  keypress.htm
< 1K Download


Wed, 18 Dec 2002 03:00:00 GMT  
 Capturing Keys to Select Radio Buttons
Perfect!  Thanks for the quick response Mark.


Quote:
>This is a multi-part message in MIME format.

>------=_NextPart_000_001A_01BFE36A.1582DEC0
>Content-Type: text/plain;
>    charset="Windows-1252"
>Content-Transfer-Encoding: quoted-printable

><html>
><head>
><script>
>function go() {
>if(window.event.keyCode=3D=3D"65"||window.event.keyCode=3D=3D"97")
>one(0).checked=3Dtrue;
>if(window.event.keyCode=3D=3D"66"||window.event.keyCode=3D=3D"98")
>one(1).checked=3Dtrue;
>if(window.event.keyCode=3D=3D"67"||window.event.keyCode=3D=3D"99")
>one(2).checked=3Dtrue;
>}
></script>
></head>
><body onkeypress=3Dgo()>
><input type=3Dradio name=3Done>a<p>
><input type=3Dradio name=3Done>b<p>
><input type=3Dradio name=3Done>c
></body>
></html>
>--=20
>Mark L. Ferguson    Please reply in Newsgroup
>marfer's notes for OE 5 > =
>http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm


>> I'm totally new to JavaScript (I'm normally an ASP/SQL guy), but I
>> have a need to select a radio button based on keyboard input. =20
>>=20
>> For example, I have three choices for the radio group A, B, and C.  I
>> want the user to simply press A, B, or C on the keyboard instead of
>> having to click the choice.  Any sample code would be appreciated.
>>=20
>> corbin

>------=_NextPart_000_001A_01BFE36A.1582DEC0
>Content-Type: text/html;
>    name="keypress.htm"
>Content-Transfer-Encoding: 7bit
>Content-Disposition: attachment;
>    filename="keypress.htm"

><html>
><head>
><script>

></script>
></head>
><body onkeypress='window.status=window.event.keyCode'>

></body>
></html>
>------=_NextPart_000_001A_01BFE36A.1582DEC0--



Wed, 18 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Capture radio button checked value

2. Finding the index of a selected Radio button-HELP

3. selecting radio buttons

4. HOWTO Populate Select Based On Radio Button Selection

5. Determining the which radio button is selected

6. Selecting/Disabling radio buttons

7. Disable button and change button value at radio

8. Create radio button set using Push Buttons?

9. Capture backspace key on form's text

10. capturing F1 key?

11. Capturing the Enter Key

12. Capture a key stroke

 

 
Powered by phpBB® Forum Software