Solved

radio input "name" property when runat server

Posted on 2011-02-15
4
637 Views
Last Modified: 2012-06-27
hi

i have the following html

<label id="labelForYes" for="radioYes">Yes</label>
            <input id="radioYes" type="radio" name="radioGroup"
                runat="server" value="1" />
            <label id="labelforNo" for="radioNo"> No</label>
            <input id="radioNo" type="radio" name="radioGroup"
                runat="server" value="0" />

-------------------------------------

then i want to capture the click event when any radios in that group are clicked.
then get the value of the one radio that was selected...
so i thought i would use this code

  $(document).ready(function() {
        $("#radioGroup input").click(function(){            
               //get the value of the radio that has been selected..
            });

however, this doesnt work as "radioGroup" is getting renamed by asp.net.
because i need it to be runat server.

can anyone tell me how to access the "real/client" value of name

thanks

0
Comment
Question by:MrKevorkian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:devlab2012
ID: 34897456
Change the code to:

<label id="labelForYes" for="radioYes">Yes</label>
            <input id="radioYes" type="radio" name="radioGroup" onclick="processRadio(1);"
                runat="server" value="1" />
            <label id="labelforNo" for="radioNo"> No</label>
            <input id="radioNo" type="radio" name="radioGroup" onclick="processRadio(0);"
                runat="server" value="0" />
0
 
LVL 13

Assisted Solution

by:devlab2012
devlab2012 earned 150 total points
ID: 34897492
Please refer to my prev comment. Now you can create a function processRadio as:

function processRadio(radioValue)
{
    if (radioValue == 1)
    {
            //code for YES
    }
    else
    {
             //code for NO
    }
}
0
 
LVL 1

Accepted Solution

by:
MrKevorkian earned 0 total points
ID: 34897804
thanks, that would be a good solution.

i discovered i can do this if i turn my inputs into an asp:radiobuttonlist.

        $('#<%= radioButtonList.ClientID %>').click(function() {
0
 
LVL 1

Author Closing Comment

by:MrKevorkian
ID: 34936408
i found the answer to this myself, although i was given another good option
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question