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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:53:30+00:00 2026-05-26T15:53:30+00:00

I am trying to parse through all elements in a single radio button (or

  • 0

I am trying to parse through all elements in a single radio button (or check box).
In my code, $(this) refers to a specific radio button or checkbox…

What I want is to create a function using ‘each’ which parses through all values of a radio or check box..

The code I am trying to create is shown below–

...SOME CODE....
...SOME CODE....
else if (($(this).attr('type')=="radio")||($(this).attr('type')=="checkbox"))
             {
                $(this).<WHAT SHOULD BE THE CODE HERE>.each(function(){ 

                        alert( " Option value=" + $(this).val() );    

                });
             }

What should be the code at the place indicated above, so that I can parse through all elements of a radio button/check box. Also, I want to obtain both text values and assigned values, I suppose this can be done using text() and val() respectively?

EXAMPLE OF A CHECK BOX —

 <input type="checkbox" name="color" value="red1">
 Red<br>

<input type="checkbox" name="color" value="yellow1">
Yellow<br>

<input type="checkbox" name="color" value="blue1">
Blue<br>

<input type="checkbox" name="color" value="orange1">
Orange<br>

<input type="checkbox" name="color" value="green1">
Green<br>

 <input type="checkbox" name="color" value="purple1">
 Purple<br>

As can be seen from above example, for each element of the checkbox, using val() should fetch “red1”, “yellow1”, “blue1” and so on…while using text() should fetch “Red” “Yellow” “Blue” and so on…

  • 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-26T15:53:30+00:00Added an answer on May 26, 2026 at 3:53 pm
    $('input[type="checkbox"], input[type="radio"]').each(function(){
      $('[name="' + $(this).prop('name') + '"]').each(function(){ 
        // Do stuff here with $(this).val();
        // Should be red1, yellow1, blue1, ...
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse through a string with regular expressions (.NET) and find all
I'm trying to parse CSV files uploaded by the user through PHP, but it's
I'm trying to fetch and parse an XML-file through JavaScript. I don't control the
Trying to parse an HTML document and extract some elements (any links to text
Trying to parse some XML but apparently this is too much for a lazy
I'm trying to parse through fixed-width formatted file extracting x,y values of points from
I'm able to parse through the directory and list all images with any of
I am trying to connect to FTP server through the c# code and I
I'm running through an XML document, selecting all the elements, and creating links based
I am trying to parse this XML file with this type of layout: <POX>

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.