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 513131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:23:27+00:00 2026-05-13T07:23:27+00:00

I’m developing an online baseball/softball scorebook application. I want to visually change the CSS

  • 0

I’m developing an online baseball/softball scorebook application. I want to visually change the CSS of the specific table cell (a specific TD) when the user changes the value of one of the radio buttons inside that TD is selected.

Here is a JPG of what the table looks like: http://www.ppgeez.com/images/gt_ab.jpg

There are 12 players and each player can have a maximum of 6 AB’s. The code below is an example of a single At-Bat (AB) for a player where you can specify what the player did for that particular AB.

    <td>
  <table border=1>
    <tr>
      <td>
    <table border=0 cellspacing=0 cellpadding=0>
        <tr><td><input type=radio name=p1o1 value="1B">1B
            <td><input type=radio name=p1o1 value="FO">FO
        <tr><td><input type=radio name=p1o1 value="2B">2B
            <td><input type=radio name=p1o1 value="GO">GO
        <tr><td><input type=radio name=p1o1 value="3B">3B
            <td><input type=radio name=p1o1 value="FC">FC
        <tr><td><input type=radio name=p1o1 value="HR">HR
            <td><input type=radio name=p1o1 value="SF">SF
        <tr><td><input type=radio name=p1o1 value="BB">BB
            <td><input type=radio name=p1o1 value="K" >K
        <tr><td><input type=radio name=p1o1 value="RE">RE
            <td><input type=radio name=p1o1 value="DP">DP
   </table>

      <td valign=top align=center>
        Run<br><input type=checkbox name=p1run1><br><hr>
        RBIs<br><select name=p1rbi1>
                <option value=0>0
                <option value=1>1
                <option value=2>2
                <option value=3>3
                <option value=4>4
                </select><p>
        <input type=radio name=p1o1 value="NA" checked>N/A
      <td>

  </table>
<td>

I’m want to visually highlight (by changing the background color of the TD) each AB that is ‘completed’. Basically, when the form loads, the “N/A” radio button is selected by default. If any other radio button is selected (1B, 2B, K, etc…) then that TD should be highlighted. If N/A is selected again, it should be unhighlighted. I’m not sure where to start, any help would be appreciated. Thanks!

UPDATE: Final Working Code – I used a function from below, but since I was using nested tables the trick was to select the specific one I wanted using eq(x).

    $("td input[type=radio]").change(function () {
  function clearTable(){
  var table = $(this).parents('table:eq(0)');
    $(table).removeClass('selected');
  }
  $('input[value="NA"]').click(clearTable);
  var table = $(this).parents('table:eq(1)');
  if (this.value != 'NA') {    
    table.addClass('selected');
    }
}); 

UPDATE – GIVE ALL TABLES SPECIFIC CLASS

// set each table with the atBat class
ABtables = $(‘input[type=”checkbox”]’).closest(‘table’);
ABtables.each(function() { $(this).addClass(‘atBat’); });

  • 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-13T07:23:27+00:00Added an answer on May 13, 2026 at 7:23 am

    Table cell highlight

    $(function(){
      function clearTable(){
        $('td.selected', table).removeClass('selected');
      }
      var table=$('input[value="1B"]').closest('table');
      $('input[value="NA"]').click(clearTable);
      $(':radio', table).click(function(){
        clearTable();
        $(this).closest('td').addClass('selected');
      });
    });
    

    EDITED CODE IN RESPONSE TO COMMENTS

    //assuming you've given the class atBat to any table which might be selected
    $('table.atBat').each(function(){
      var table=$(this);//cache the current iteration
      var childTable=table.find('table:first');
       //replace above click handler with this
       $(':radio', childTable).click(function(){
        if ($(this).val()==='NA'){
          table.removeClass('selected');
        }
        else {
         table.addClass('selected');
        }
       });
    })
    

    Hope this helps, good luck!

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
I want to show the soap response to UIWebview.. my soap response is, <p><img

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.