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

  • SEARCH
  • Home
  • 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 6644127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:07:52+00:00 2026-05-26T00:07:52+00:00

I wanted to have the radio button check when its particular row is clicked,

  • 0

I wanted to have the radio button check when its particular row is clicked, but it is not working. I’m suspecting jquery selector problem with ajax/json generated table. This is my code listing. I’m a Stackoverflow newbie.

            <html>
            <head>
            <script type="text/javascript" src="<?php echo base_url();?>js/jquery-1.6.1.min.js"></script>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Untitled Document</title>
            <style type="text/css">
            <!--

            .selected td { background-color: #FF0000; }

            -->
            </style>
            </head>
            <body>
            <div id="search_form">
              <form id="form1" name="form1" method="post" action="">
                  <table width="80%" border="1" align="center" cellspacing="0">
                    <tr>
                      <td><label>
                        <div align="center">
                          <p>
                            <input name="search_input" type="text" id="search_input" value="ASET" size="50" />
                          </p>
                        </div>
                      </label></td>
                      <td width="10%" rowspan="2"><div align="center" id="btn_search">Search</div></td>
                    </tr>
                    <tr>
                      <td><label>
                        <div align="center">
                        <input name="rb_searchType" type="radio" id="cb_searchType" value="fileno" checked="checked" />
                      File No
                       <input type="radio" name="rb_searchType" id="cb_searchType2" value="filetitle" />
                      Title</div>
                      </label></td>
                    </tr>
                  </table>
                  <div align="center"></div>
                  <div align="center"></div>
              </form>
            </div>

            <div id="status_submit">
            </div>
            <div id="search_result1">
            </div>
            </body>
            <script type="text/javascript">
            $(document).ready(function() {

                $('#btn_search').click(function() {
                    $('#form1').submit();
                });

                $("form").submit(function() {

                  var fSearchInputValue = $('#search_input').attr('value');
                  var fSearchType = $("input[@name='rb_searchType']:checked").val();

                 $('#status_submit').html("please wait......");
                  $.ajax({
                        type: "POST",
                        url: "<?php echo site_url('files/search_list_file_json/'); ?>"+"/",
                        data: "SearchInputValue="+ fSearchInputValue +"& SearchType="+ fSearchType,
                        dataType: "json",
                        success: function(data) {
                        var contentHtml = '<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000" id="Table"><tr><td width="5%">&nbsp;</td><td width="15%">FILE NO&nbsp;</td><td>SUBJECT&nbsp;</td></tr>';

                            $(data).each(function(index, item) {
                                contentHtml += '<tr><td><input type="radio" name="rb_fileno" id="rb_fileno" value="';
                                contentHtml += item.FileNo;
                                contentHtml += '" />&nbsp;</td>';               
                                contentHtml += '<td>';
                                contentHtml += item.FileTitle;
                                contentHtml += '&nbsp;</td></tr>';  
                            });

                        contentHtml += "</table>";
                          $('#search_result1').html(contentHtml);
                          $('#status_submit').fadeIn(function(){$('#status_submit').html('');});

                        },
                        error: function(){
                            var contentHtml='No result';
                            $('#status_submit').fadeIn(function(){$('#status_submit').html(contentHtml);});         
                        }
                    });

            return false;
                }); //end ajax json

                //check radio button when row is clicked
                 $('#search_result1s tr').click(function(event) {
                    // $(data).filter('div.search_result1 tr').click(function(event) {

                    $(this).find('td input:radio').prop('checked', true);
                    $(this).addClass("selected").siblings().removeClass("selected");
                 });

            }); // end document.ready

            </script>
            </html>

Thanks

  • 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-26T00:07:52+00:00Added an answer on May 26, 2026 at 12:07 am

    Try this

    $('#search_result1s tr').live('click',function(event) {
        $(this).find('td :input[type=radio]').attr({'checked':'checked'});
         ...
    });
    

    basically .live() method works similar to .click() only difference is when you add html element dynamically to body means after page has been loaded then .live() succeed but .click() method fails.

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

Sidebar

Related Questions

Possible Duplicate: jQuery attribute selector for multiple values I have this $('input:radio[name=foo]').change(function() { blah();
I have wanted to try to use knockout.js but have not really needed it.
I have wanted to try GAE since launch, but coming from ASP .NET and
I currently have this and it works fine but I wanted to have a
I am programming in Ruby and have wanted to learn about matrices but I
C# code. I have populated checkboxes, but not radiobuttons before. Here is a sample
<input type=radio id=Check name=color> <label for=Check >Check it</label> if i wanted to call the
I wanted to have some radio buttons that disabled when the mouse went over
I wanted to have a list of lambdas that act as sort of a
So I wanted to have something like in this image . Basically you have

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.