SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    click textbox js selects radio button

    I am trying to use some javascript on my form. I have three radio buttons. To the right of each radio button is a textbox. If they click in any textbox, I want the radio button to the left of that textbox to be clicked, but the focus needs to stay in the textbox. All three of the radio buttons have the same name, but different values. Anyone have any ideas on how to do this? Thanks...

  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    And here is the answer:

    <script type="text/javascript">
    //text box select and focus
    function RDD_Day_setfocus()
    {
    document.forms[0].RDD_Day.select()
    document.forms[0].RDD_Day.focus()

    }
    //text box select and focus
    function RDD_Date_setfocus()
    {
    document.forms[0].RDD_Date.select()
    document.forms[0].RDD_Date.focus()
    }
    </script>

    <input type="radio" name="Radio_Search_RDD" value="Day">
    <input onclick="blur();document.FormName.Radio_Search_RDD[0].checked=true;RDD_Day_setfocus()" name="RDD_Day" type="text" value="Yes">

    <input type="radio" name="Radio_Search_RDD" value="Date">
    <input onClick="blur();document.FormName.Radio_Search_RDD[1].checked=true;RDD_Date_setfocus()" name="RDD_Date" type="text" value = "No">


    This post was for my friend, so he finally figured it out.


Bookmarks

Posting Permissions

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