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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:21:56+00:00 2026-05-24T12:21:56+00:00

I’ve an HTML page with a number of tables, one for each user in

  • 0

I’ve an HTML page with a number of tables, one for each user in the database.
The first four columns of each table are radio buttons, with the values: G, A, X and blank respectively.

What I want to do is set the radio button to e.g. ‘A’ for all rows that are currently blank.

Here was where I started:

var st='A';
$('#user123 input').val([st]);

This works, but it also sets to A the rows that were already ‘G’ or ‘X’.

Here is what I’ve tried that didn’t work:

$('#user123 input[value=]').siblings().val([st]);

(nothing gets set)

$('#user123 input[value=]').parent().children().val([st]);

(the blank radio button gets cleared, none get set)

$('#user123 input[value=]').val([st]);

(the blank radio button gets cleared, none get set)

$('#user123 input').not('[value=G]').val([st]);

(planning to add exceptions for A and X later, but it already doesn’t work – all radio buttons get set to ‘A’, not just the blank ones)

I’m really close aren’t I? But I just cannot find the magic incantation I need!

Here is a cut-down version of the table HTML:

<table id="user123">
<tr>
<td><input name="r520" value="G" type="radio"></td>
<td><input name="r520" value="A" type="radio"></td>
<td><input name="r520" value="X" type="radio"></td>
<td><input name="r520" value="" type="radio" checked></td>
<td>2011-06-01</td>
</tr>
<tr>
<td><input name="r767" value="G" type="radio"></td>
<td><input name="r767" value="A" type="radio"></td>
<td><input name="r767" value="X" type="radio"></td>
<td><input name="r767" value="" type="radio" checked></td>
<td>2011-06-03</td>
</tr>
</table>

UPDATE
Thanks for replies; here is the solution I went with (mainly inspired by michelpm’s):

var st='A';
$('#user123 tr').each(function() {
    if($("input:radio[value=]:checked",this).length){
        $("input:radio[value="+st+"]",this).attr("checked",true);  
        }
    });
  • 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-24T12:21:56+00:00Added an answer on May 24, 2026 at 12:21 pm

    If by blank you meant no radio is checked in that row:

    http://jsfiddle.net/michelpm/GzPrd/

    $("#user123 tr").each(function() {
        if($(":radio:checked", this).length == 0) {
            $(":radio[value=A]", this).attr("checked", true);        
        }
    });
    

    EDIT:

    If you want so bad to do that in one line this one may do the trick…

    http://jsfiddle.net/michelpm/GzPrd/2/

    function select(value) {
         return function() {
            $(":radio[name=" + this.name + "][value=" + value + "]")
                .attr("checked", true);
        }; 
    }
    
    $("#user123 :radio:not([value]):checked").each(select('A'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.