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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:30:06+00:00 2026-05-22T01:30:06+00:00

I am trying to get all input textboxes, radio groups, checkboxes etc. I am

  • 0

I am trying to get all input textboxes, radio groups, checkboxes etc. I am having trouble getting the selected radio and checkboxs values, I cant figure it out.

I can get the text boxes but can’t seem to get the “selected” in the right place. At the moment it just gets the first value for radio/checkboxes not the selected value.

$('#form_1 input').each(function(key)               
    formData += '&'+$('#'+this.id).attr('name')+'='+$('#'+this.id).val();   
});

Thanks

EDITED

$('#form_1 input').each(function(key, value) {              
    if ((this.type === "radio" || this.type === "checkbox") && this.checked === true) {
         val = this.value;
    } else {
         val = this.value;
    }

    alert($('#'+this.id).attr('name') + ' = ' + val);
    formData += '&'+$('#'+this.id).attr('name')+'='+val;    
});

Ok now I get every value for radios etc so I am a step closer. Just need to get the values of selected radios now.

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-22T01:30:07+00:00Added an answer on May 22, 2026 at 1:30 am
    var val;
    if (this.type === "radio" || this.type === "checkbox") {
         val = this.checked;
    } else {
         val = this.value;
    }
    

    For radios and check boxes you care about the checked attribute.

    Update

    You wrote

    (this.type === "radio" || (this.type === "checkbox" && this.checked === true))

    You meant

    ((this.type === "radio" || this.type === "checkbox") && this.checked === true)

    You need those brackets in the right place.

    Further edit

    The logic was a bit broken.

    Basically what you want.

    if ((this.type === "radio" || this.type === "checkbox") && this.checked === false) {
        return;
    }
    

    This means if its a non-checked radio/checkbox you do nothing.

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

Sidebar

Related Questions

I'm trying to get all the input elements from a certain form from jQuery
I'm trying to get all property names / values from an Outlook item. I
i am trying to get values of checkboxes to insert them later on in
I'm trying to get the values from multiple textboxes using JQuery. I'm a bit
I am trying to select all my textboxes with... $(input[@type=text]) From the jquery docs
I'm trying to get all of my checkboxes to be checked when clicking a
Im having troubles trying to get the autocomplete to work properly. It all looks
I am trying to get all checkboxes checked with: <script type=text/javascript> $(document).ready(function() { $(#delmsg_all).click(function()
iam trying to get all object's xpath's from loaded page via selenium something similar
I'm trying to get all the direct reports of a User through Active Directory,

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.