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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:35:16+00:00 2026-05-15T14:35:16+00:00

I have a page where the input type always varies, and I need to

  • 0

I have a page where the input type always varies, and I need to get the values depending on the input type. So if the type is a radio, I need to get which is checked, and if it is a checkbox I need to now which are checked, and if it is a drop down I need to know which is selected, and I if it is a text/textarea I need to know the values.

Any idea on how to do that?

  • 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-15T14:35:17+00:00Added an answer on May 15, 2026 at 2:35 pm

    EDIT Feb 1, 2013. Due to the popularity of this answer and the changes to jQuery in version 1.9 (and 2.0) regarding properties and attributes, I added some notes and a fiddle to see how it works when accessing properties/attributes on input, buttons and some selects. The fiddle here: http://jsfiddle.net/pVBU8/1/


    get all the inputs:

    var allInputs = $(":input");
    

    get all the inputs type:

    allInputs.attr('type');
    

    get the values:

    allInputs.val();
    

    NOTE: .val() is NOT the same as :checked for those types where that is relevent.
    use:

    .attr("checked");
    

    EDIT Feb 1, 2013 – re: jQuery 1.9 use prop() not attr() as attr will not return proper values for properties that have changed.

    .prop('checked');
    

    or simply

    $(this).checked;
    

    to get the value of the check – whatever it is currently. or simply use the ‘:checked’ if you want only those that ARE checked.

    EDIT: Here is another way to get type:

    var allCheckboxes=$('[type=checkbox]');
    

    EDIT2:
    Note that the form of:

    $('input:radio');
    

    is perferred over

    $(':radio');
    

    which both equate to:

    $('input[type=radio]');
    

    but the “input” is desired so it only gets the inputs and does not use the universal ‘*” when the form of $(':radio') is used which equates to $('*:radio');

    EDIT Aug 19, 2015: preference for the $('input[type=radio]'); should be used as that then allows modern browsers to optimize the search for a radio input.


    EDIT Feb 1, 2013 per comment re: select elements
    @dariomac

    $('select').prop("type");
    

    will return either “select-one” or “select-multiple” depending upon the “multiple” attribute and

    $('select')[0].type 
    

    returns the same for the first select if it exists. and

    ($('select')[0]?$('select')[0].type:"howdy") 
    

    will return the type if it exists or “howdy” if it does not.

     $('select').prop('type');
    

    returns the property of the first one in the DOM if it exists or “undefined” if none exist.

    $('select').type
    

    returns the type of the first one if it exists or an error if none exist.

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

Sidebar

Related Questions

I have an input field on my page where the user will type in
I have a page that, depending on input from a previous page, lists a
I have a login page with an input of type password I would like
I want to create a simple gsp page which will have an input box
I have a simple text box and button type input on my page. <input
I have a page with two input fields City and Venue. I have the
I have a page with File html input field and a Submit button as
I have a page where I combine labels, input boxes and text areas to
I have a page with a button and a textbox, when a input <string>
I have a web page where it will input an excel/CSV file from the

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.