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

  • Home
  • SEARCH
  • 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 4618940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:21:27+00:00 2026-05-22T02:21:27+00:00

Here is a live example of my problem http://jsfiddle.net/littlesandra88/xksB9/ I would have expected that

  • 0

Here is a live example of my problem

http://jsfiddle.net/littlesandra88/xksB9/

I would have expected that the “Create” button returned an empty string, when its radio buttons are not selected. Instead it reads the value from the radio buttons from the form below.

The bottom “Save” button always returns the value from the form above. Very strange!

Here is the code

$(document).ready(function(){

   $('form').live('submit', function(){

      var title      = this.elements.title.value;
      var owner      = this.elements.owner.value;

      var type = $('input:radio[name=ctype]:checked').val() || '';

      alert(type);

    });
});

The idea is, I will auto-generate forms of the type at the bottom, and so don’t know the ID’s before hand, so I just give them random numbers to make them unique.

How can this problem be solved?

  • 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-22T02:21:27+00:00Added an answer on May 22, 2026 at 2:21 am

    You may want to just change this line:

    var type = $('input:radio[name=ctype]:checked').val() || '';
    

    to

    var type = $('#create_form input:radio[name=ctype]:checked').val() || '';
    

    So that jQuery only looks in the top form, rather than in whole DOM.

    Not sure what the overall goal is, but that edit at least gets you the behavior you’re looking for.

    If you want the individual save buttons to function in a similar way, change it to:

    var type = $(this).find('input:radio[name=ctype]:checked').val() || '';
    

    EDIT

    To get the other forms to work, you need to change the HTML a bit so that the form tags wrap the tables, and not the other way around. This is what I changed each for to (notice that this would make multiple tables instead of one table):

    <form action="" method="post">
      <input name="anchor" value="54" type="hidden">
      <table class="alerts" cellspacing="0">
        <tbody>
          <tr>                                
            <td class="activity-data">54</td>
            <td class="activity-data"> <input name="title" id="54_title" value="" type="text" /> </td>
            <td class="activity-data"> <input name="owner" id="54_owner" value="" type="text" /> </td>          
            <td class="activity-data"> <input name="ctype" value="individuel" type="radio" checked/> Individuel <br> <input name="ctype" value="course" type="radio" /> Course </td>
            <td> <input value="Save" type="submit" /></td>
          </tr>
        </tbody>
      </table>
    </form>
    

    This way, the radio buttons are proper children of the forms and jQuery is happy about that.

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

Sidebar

Related Questions

Here is a live example: http://jsfiddle.net/Pzvdv/ <ul id=navigation> <li><a href=#>HOME</a></li> <li><a href=#>OUR APPROACH</a></li> <li><a
here's a live example of the problem - http://marksportfolio.herokuapp.com/folio/ when the rightjs lightbox loads,
So basically here is my jsFiddle - http://jsfiddle.net/CmNFu/ . And code also here -
I have normal table, nothing special about it, here it is: live example :
Consider the following example: ( live demo here ) HTML: <div class=board> <div class=row>
Here is my problem: I have made a small bar in the left side
I have got a button that only appears when it hits a certain media
I have a problem with a flexbox (accordion). In the example feedled below I
I want make validation jquery without using from plugin , problem is here that
I have an iframe that acts as a big button. The entire content inside

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.