Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1030583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:43:25+00:00 2026-05-16T12:43:25+00:00

I’m pulling my hair out trying to get a jQuery script working that will

  • 0

I’m pulling my hair out trying to get a jQuery script working that will pick up the selected value in a RadioButtonList. I’ve done the usual thing when I can’t get a script to run – cut and paste somebody else’s into a blank page, get it working and then copy into the required page.

I have tried three different scripts, however, that take different approaches to defining the selected value but I can’t get any of them to work, even though comments on some of the webpages I got them from seem to suggest that they are working for other people.

This script throws an unrecognised expression error:

//In head with prior reference to local copy of jquery-1.4.1.js
<script language="javascript">
    $(document).ready(function() {
        $("#btnSubmit").click(function() {
            alert($("#RadioButtonList1").find("input[@checked]").val());
        });
    });
</script>

//In body
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
   <asp:ListItem>3</asp:ListItem>
</asp:RadioButtonList>
 <input id="btnSubmit" type="button" value="Submit" />

In the following code, the alert box justs gives ‘undefined’ (Note I’ve tried it with both the remote reference and reference to local copy of jquery-1.4.1.js )

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
  <title></title>

  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
  <form id="form1" runat="server">
   <div>
    <asp:RadioButtonList ID="RadioButtonList1" runat="server">
        <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
        <asp:ListItem Text="No" Value="2"></asp:ListItem>
    </asp:RadioButtonList>
   </div>
   <input type="button" id="btnTest" value="Uncheck" />
  </form>
</body>

<script type="text/javascript">

 $('#btnTest').click(function () {
    alert($('#<%=RadioButtonList1.ClientID %> input[type=radio]:checked').val());
 });

</script>

</html>

I’ve also tried the following in a basic HTML page (i.e. not asp.net) and it does nothing

//In head
$("input[@name='option_layout']").change(
function()
{
    if ($("input[@name='option_layout']:checked").val())
        $(".group").toggleClass("group_vert");
    else
        $(".group").toggleClass("group_vert");
    $(this).blur();
}
);

//In body
<input type="radio" name="option_layout" value="0" checked="checked" />
<input type="radio" name="option_layout" value="1" />

I’ve tried modifying .change to .click as I know that there is a bug in IE with .change, even though I had tested with no success in both IE and Fiefox. I also tried wrapping the code inside a $(document).ready(function() block but no difference. I’ve also tried adding an alert box into the first line of the function but it again throws an unrecognised expression error.

Anyone any idea what is going wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:43:26+00:00Added an answer on May 16, 2026 at 12:43 pm

    The @ was deprecated/removed from attribute selectors in jQuery 1.3, so your first attept should look like this:

    $(document).ready(function() {
      $("#btnSubmit").click(function() {
        alert($("#RadioButtonList1 input[checked]").val());
      });
    });
    

    Or a bit more simplified using the :checked selector:

    $(function() {
      $("#btnSubmit").click(function() {
        alert($("#RadioButtonList1 :checked").val());
      });
    });
    

    Also, here’s what I think you’re after in the third attempt, just as a starting point 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.