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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:05:23+00:00 2026-05-13T11:05:23+00:00

I have the following and in this order: <script type=text/javascript> $(document).ready(function(){ var overwrite =

  • 0

I have the following and in this order:

<script type="text/javascript">
  $(document).ready(function(){
     var overwrite = $('#itemList input:radio:checked').val() 

     alert('value = '+ overwrite);
  });
</script>
<body>
  <form ..... >
    <div id="itemList">
    Overwrite?
    <input type="radio" value="Yes" class="overWrite" name="overWrite" >Yes
    <input type="radio" value="No" class="overWrite" name="overWrite" >No
    </div>
  </form>
</body>

when it runs, the alert will have ‘value = undefined’

BUT, if I put the javascript after the div (or body), the alert comes back with ‘value = Yes’

Why does jquery not recognize the type radio at beginning of page? If I create a type = ‘hidden’, jquery can read/recognize the value if at beginning of page. When type = ‘radio’, behaviour is different

  • 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-13T11:05:24+00:00Added an answer on May 13, 2026 at 11:05 am

    Problem you’re running into seems to be that there are simply no checked radio buttons on page load so your jquery returns a null object.

    This will check “no” by default and returns the correct value. So your javascript is technically correct, you just need to check for null values

    <head>
    <title>jQuery Tester</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    
    </head>
    
    <body>
        <div id="itemList">
        Overwrite?
        <input type="radio" value="Yes" class="overWrite" name="overWrite"  />Yes
        <input type="radio" value="No" class="overWrite" name="overWrite" checked="checked" />No 
        </div>
    
    
    <script type="text/javascript">
      $(document).ready(function(){
         var overwrite = $('#itemList input:radio:checked').val();
    
         alert('value = ' + overwrite);
      });
    </script>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following: <script type=text/javascript> $(document).ready(function () { $(input[id^='Position_'], select[id^='Level_'], input[id^='Title_'], select[id^='Status_'],).change(function (e)
I have this javascript: <script type=text/javascript> $('.publish_post').click (function(){ var info = 'some info'; $.ajax({
I have the following piece of code: <html> <head> <script src=myplugin.js /> <script> $(document).ready(function()
I have the following very simple Javascript-compatible regular expression: <script type=text/javascript id=(.+) src=([^]+)> I
I have the following call in my RoR script: Foo.where(event = 'Login').group('user_id').order('user_id ASC').count() This
I have this following numpy matrix that I want to sort in ascending order
I have this following jquery text fly-in animation.Here is my code before I explain
I have this following IEnumerable LINQ query: var query = from p in Enumerable.Range(2,
I'm currently working on a PHP/MySQL script that does the following, in this order:
In script#, I have the following: jQuery.Select(#someId).Trigger(item-added, new object[]{ball} ); This compiles into 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.