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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:46:38+00:00 2026-05-23T09:46:38+00:00

I am confused about this code its self explanatory what its supposed to do

  • 0

I am confused about this code its self explanatory what its supposed to do but it doesn’t do it

<input  name="property" type="radio" checked value="1" />Station Masters House
<input  name="property" type="radio" value="2" />Railway Carriage

<br><br>
<div id="fillin">press</div>

$("#fillin").click(function() {    
        if ($('input[name=property]').val() == "1")
        {

            alert($('input[name=property]').val());

        } else if ($('input[name=property]').val() == "2") {

            alert($('input[name=property]').val());
        }


    });

example here

http://jsfiddle.net/BFf5H/40/

  • 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-23T09:46:39+00:00Added an answer on May 23, 2026 at 9:46 am

    input[name=property].length === 2 … therefore, .val() won’t work. (.val pulls the value of the first element in the DOM that it finds that matches the requested selector, except in the case of a <select multiple> element.)

    Try input[name=property]:checked instead.

    $("#fillin").click(function() {    
        if ($('input[name=property]:checked').val() == "1")
        {
    
            alert($('input[name=property]:checked').val());
    
        } else if ($('input[name=property]:checked').val() == "2") {
    
            alert($('input[name=property]:checked').val());
        }
    
    
    });
    

    Better yet, cache the things you need, so you are only hitting the DOM (or in this case, jQuery’s cache) once:

    $("#fillin").click(function() {
       var val = $('input[name=property]:checked').val();
        if ( val == "1") {
            alert(val);
        } else if (val == "2") {
            alert(val);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm confused about this bit of code from the HTTP package : type HandlerFunc
I'm VERY confused as to why this code Html.ActionLink(About, About, Home, new { hidefocus
I can't believe I'm still confused about this but, any way, lets finally nail
I am a bit confused about this piece of code. public static void Foo(A
Though I'm trying to understand why this is needed, I'm very confused about its
I am a bit confused about this. If you're building a distributed application, which
I'm confused about this. Most of us have been told that there isn't any
I am getting myself a bit confused about how to go about this. My
I'm learning C++ and I'm still confused about this. What are the implications of
As demonstrated in this answer I recently posted, I seem to be confused about

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.