Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Hot Key on Radio Button?

    Is there any way to setup a hotkey on a radio button?

    For instance I have four radio buttons...

    o 1 o 2 o 3 o 4


    Is there a way to set up if i press 1 then the first radio will be selected, then it can go to the next set of radio buttons.

    Thanks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,308
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Not really. You would need to enter "1" and so on into form field.

    Code:
    <form name = "myform">
    
    ONE <input type = "radio" name = "rad1">
    TWO <input type = "radio" name = "rad1">
    THREE <input type = "radio" name = "rad1">
    FOUR<input type = "radio" name = "rad1">
    <br>
    <br>
    <input type = "text" name= "box1" size = "1" maxlengh = "1" onblur = "go()">
    </form>
    
    <script type = "text/javascript">
    function go() {
    var x = parseInt(document.myform.box1.value);
    if (x >=1 && x <=4) {
    document.myform.rad1[x-1].checked = true;
    }
    }
    
    </script>

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Is there anyway to set it up without using a textbox to type in the number?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,308
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by hawkeyefan View Post
    Is there anyway to set it up without using a textbox to type in the number?
    Nope. You could capture a keypress anywhere within the document with onkeydown() but that would mean that the user would be unable to type in the keys 1-4 without triggering the radio group check.
    Last edited by Philip M; 06-23-2009 at 09:48 PM.

  • Users who have thanked Philip M for this post:

    hawkeyefan (06-23-2009)

  • #5
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Nope. You could capture a keypress anywhere within the document with onkeydown() but that would mean that the user would be unable to type in the keys 1-4 without triggering the radio group check.
    Yeah that is what I am going for, but I want to have about 4 rows of buttons, so its not like I could select the first set of radio buttons use 1-4 and then goto the next set of radio buttons and then do 1-4.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •