Requires help from Super-MVP: Need JavaScript to produce behavior of radio button in 2 groups?

Discussion in 'ASP .Net' started by Amelyan, Jun 16, 2005.

  1. Amelyan

    Amelyan Guest

    When we want radio button to belong to a group name we say,
    radio1.GroupName="GroupA". In this case, radio1 will be unselected if
    another radio button is selected in "GroupA".

    Is there a way (trick, custom RadioButton, or javascript) to make radio
    button (radio1) belong
    to 2 independent radio button groups instead of one? This would be an
    equivalent of sayting something like
    radio1.GroupName1 = "GroupA";
    radio1.GroupName2 = "GroupB";

    Hence, whenever radio button is selected in one of the two groups, radio1 is
    unselected. Also, I need a non-postBack solution. Client side
    functionality, just like single Group radio button.

    Thanks,
    Amelyan

    PS> Example of what I need to accomplish:

    Imagine that you have a matrix/grid of radio buttons with, for examle,
    3 rows and 3 columns.

    O O O
    O O O
    O O O

    When you check a radio button in this matrix, you don't want anything
    else selected in the same row and column. One neat way to accomplish
    this is if there was a way to have radio button belong to two groups,
    e.g. "Row2" and "Column2".

    Thanks,
    -Amelyan
     
    Amelyan, Jun 16, 2005
    #1
    1. Advertising

  2. Amelyan

    Random Guest

    You won't get this behavior from any existing controls that I'm aware of.
    It certainly isn't standard radio button functionality.

    The simplest solution would be to NOT use the ASP.NET controls, but just
    work with the html for the buttons. In your client-side javascript then,
    add the radio buttons to arrays that make up the grouping behavior you want
    them to have. You can also make this a two-dimensional array so you
    effectively have an array of arrays (makes it easier to loop through all
    your groups/controls).

    Then you'll have to write a javascript function to handle the even (onClick
    or onBlur), and iterate through your arrays to get the behavior you want.

    Overall, it's not as difficult as it seems. If you're going to be using
    this a lot, you might want to write this functionality into a new ASP.NET
    custom control. Post it on SourceForge and share it with the rest of us!

    Random


    "Amelyan" <> wrote in message
    news:...
    > When we want radio button to belong to a group name we say,
    > radio1.GroupName="GroupA". In this case, radio1 will be unselected if
    > another radio button is selected in "GroupA".
    >
    > Is there a way (trick, custom RadioButton, or javascript) to make radio
    > button (radio1) belong
    > to 2 independent radio button groups instead of one? This would be an
    > equivalent of sayting something like
    > radio1.GroupName1 = "GroupA";
    > radio1.GroupName2 = "GroupB";
    >
    > Hence, whenever radio button is selected in one of the two groups, radio1
    > is
    > unselected. Also, I need a non-postBack solution. Client side
    > functionality, just like single Group radio button.
    >
    > Thanks,
    > Amelyan
    >
    > PS> Example of what I need to accomplish:
    >
    > Imagine that you have a matrix/grid of radio buttons with, for examle,
    > 3 rows and 3 columns.
    >
    > O O O
    > O O O
    > O O O
    >
    > When you check a radio button in this matrix, you don't want anything
    > else selected in the same row and column. One neat way to accomplish
    > this is if there was a way to have radio button belong to two groups,
    > e.g. "Row2" and "Column2".
    >
    > Thanks,
    > -Amelyan
    >
     
    Random, Jun 16, 2005
    #2
    1. Advertising

  3. you mean a radiobutton matrix, theres already an excellent example available
    here........

    http://www.virtualgeoff.com/junkyard/forms/radioButtonMatrix.html

    --
    Regards

    John Timney
    ASP.NET MVP
    Microsoft Regional Director

    "Amelyan" <> wrote in message
    news:...
    > When we want radio button to belong to a group name we say,
    > radio1.GroupName="GroupA". In this case, radio1 will be unselected if
    > another radio button is selected in "GroupA".
    >
    > Is there a way (trick, custom RadioButton, or javascript) to make radio
    > button (radio1) belong
    > to 2 independent radio button groups instead of one? This would be an
    > equivalent of sayting something like
    > radio1.GroupName1 = "GroupA";
    > radio1.GroupName2 = "GroupB";
    >
    > Hence, whenever radio button is selected in one of the two groups, radio1
    > is
    > unselected. Also, I need a non-postBack solution. Client side
    > functionality, just like single Group radio button.
    >
    > Thanks,
    > Amelyan
    >
    > PS> Example of what I need to accomplish:
    >
    > Imagine that you have a matrix/grid of radio buttons with, for examle,
    > 3 rows and 3 columns.
    >
    > O O O
    > O O O
    > O O O
    >
    > When you check a radio button in this matrix, you don't want anything
    > else selected in the same row and column. One neat way to accomplish
    > this is if there was a way to have radio button belong to two groups,
    > e.g. "Row2" and "Column2".
    >
    > Thanks,
    > -Amelyan
    >
     
    John Timney \(ASP.NET MVP\), Jun 16, 2005
    #3
  4. Amelyan

    Amelyan Guest

    And the Super-MVP award goes to <pause> John Timney!!!

    Thanks John. This is exactly what I was looking for!

    Amelyan


    "John Timney (ASP.NET MVP)" <> wrote in message
    news:...
    > you mean a radiobutton matrix, theres already an excellent example
    > available here........
    >
    > http://www.virtualgeoff.com/junkyard/forms/radioButtonMatrix.html
    >
    > --
    > Regards
    >
    > John Timney
    > ASP.NET MVP
    > Microsoft Regional Director
    >
    > "Amelyan" <> wrote in message
    > news:...
    >> When we want radio button to belong to a group name we say,
    >> radio1.GroupName="GroupA". In this case, radio1 will be unselected if
    >> another radio button is selected in "GroupA".
    >>
    >> Is there a way (trick, custom RadioButton, or javascript) to make radio
    >> button (radio1) belong
    >> to 2 independent radio button groups instead of one? This would be an
    >> equivalent of sayting something like
    >> radio1.GroupName1 = "GroupA";
    >> radio1.GroupName2 = "GroupB";
    >>
    >> Hence, whenever radio button is selected in one of the two groups, radio1
    >> is
    >> unselected. Also, I need a non-postBack solution. Client side
    >> functionality, just like single Group radio button.
    >>
    >> Thanks,
    >> Amelyan
    >>
    >> PS> Example of what I need to accomplish:
    >>
    >> Imagine that you have a matrix/grid of radio buttons with, for examle,
    >> 3 rows and 3 columns.
    >>
    >> O O O
    >> O O O
    >> O O O
    >>
    >> When you check a radio button in this matrix, you don't want anything
    >> else selected in the same row and column. One neat way to accomplish
    >> this is if there was a way to have radio button belong to two groups,
    >> e.g. "Row2" and "Column2".
    >>
    >> Thanks,
    >> -Amelyan
    >>

    >
    >
     
    Amelyan, Jun 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amelyan
    Replies:
    6
    Views:
    520
    Amelyan
    Jun 27, 2005
  2. Guest

    super.super.super how?

    Guest, Feb 19, 2005, in forum: Java
    Replies:
    24
    Views:
    10,864
    Darryl Pierce
    Feb 24, 2005
  3. Replies:
    5
    Views:
    490
    Luc The Perverse
    Oct 27, 2006
  4. Hiten
    Replies:
    1
    Views:
    701
    Vidar Petursson
    May 26, 2004
  5. Steven Burn

    Warning: MVP.org is not a Microsoft MVP site

    Steven Burn, Jan 10, 2004, in forum: ASP General
    Replies:
    7
    Views:
    185
    Jeff Cochran
    Jan 12, 2004
Loading...

Share This Page