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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:15:37+00:00 2026-05-22T12:15:37+00:00

I have a small web app I’m testing and previously this worked: if ($(this).is(‘:radio’)

  • 0

I have a small web app I’m testing and previously this worked:

    if ($(this).is(':radio') && $(this).is(':checked'))
    {   
        val       = $(this).val();
        saveThis  = true;
    } else if ($(this).is(':checkbox') && $(this).is(':checked')) {
        val       = true;
        saveThis  = true;
    } else if (($(this).is(':checkbox') || $(this).is(':radio'))) {
        saveThis  = false;
    } else {
        val       = $(this).val();
        saveThis  = true;
    }   

Here is the form:

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
        <legend>Capture Type:</legend>
            <input id="capture_type_onsite" name="capture_type" type="radio" value="onsite" />
            <label for="capture_type_onsite" style="width: 200px;">OnSite</label>

            <input id="capture_type_phone" name="capture_type" type="radio" value="phone" />
            <label for="capture_type_phone" style="width: 200px;">Phone</label>
    </fieldset>
</div>

But now, when I do console.log($(this)) ($this being the form element), I get:

<input id=​"contact_type_member" name=​"contact_type" type=​"radio" value>

Here is the code from above with some console.log’s thrown in:

    if ($(this).is(':radio') && $(this).is(':checked'))
    {   
    console.log('Radio checked: '+$(this).attr('name')+' '+$(this).val());
    console.log($(this));
        val       = $(this).val();
        saveThis  = true;
    } else if ($(this).is(':checkbox') && $(this).is(':checked')) {
    console.log('Checkbox checked: '+$(this).attr('name')+' '+$(this).val());
        val       = true;
        saveThis  = true;
    } else if (($(this).is(':checkbox') || $(this).is(':radio'))) {
    console.log('Checkbox or radio NOT checked: '+$(this).attr('name')+' '+$(this).val());
        saveThis  = false;
    } else {
    console.log('OTHER input: '+$(this).attr('name')+' '+$(this).val());
        val       = $(this).val();
        saveThis  = true;
    }   

Here’s what the is(:radio) is(:checked) — first if statement — shows:

Radio checked: capture_type 
[<input id=​"capture_type_onsite" name=​"capture_type" type=​"radio" value>​]

I’m trying to save with localStorage (I create an object of all form elements, then save it using JSON.stringify), then re-populate records based on which one they chose. This all worked before I implemented jQuery Mobile so I guess it must be doing something with the values, but I’m not sure. As you can see from the debugging statement, the value is empty by the time it gets to this.

Thanks in advance,
Hans

  • 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-22T12:15:38+00:00Added an answer on May 22, 2026 at 12:15 pm

    try:

    var radio_val = $('input[name=capture_type]:checked').val();
    alert('Radio Value: '+radio_val);
    

    Live Example: http://jsfiddle.net/WSqTS/9/

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

Sidebar

Related Questions

I have developed a small web app. This app allows users to upload images.
I have small web app that generate PDF files as a report. I'm trying
I am a broke college student. I have built a small web app in
So I have been developing a small ASP.NET web app in C# for my
I have a small web app. Seven pages, 3.6 KB index.html and 855.5 KB
I have a developed a small web-app in Symfony 2 and Doctrine 2. Can
So, I'm working on a small web app and I have it to a
I have a DB containing small news and a web app displaying these. I
I have an ASP.NET web app which is small yet has a fair amount
In the bug fixing of a small ASP.NET/C# web app I have made, I

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.