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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:51:12+00:00 2026-05-22T22:51:12+00:00

I want to show a submit button only when the radio button value change.

  • 0

I want to show a submit button only when the radio button value change. I will have several radio groups and the button should appear if any radio button change! Also, if radio button group value gets to default value submit button will hide again.

$("form :radio").live('change',function(){

});

My new code:

//hide the submit button on load
        $('form :submit').hide();

        //Data structure where the initial value from radio button(s) will be stored
        var dbRadios = [];

        //Getting the initial values from the radio button(s) and load them to the data structure
        $("form :radio:checked").each(function() {
            dbRadios.push($(this).attr('value'));
        });


        //Attach onclick event to radio button(s)
        $('form :radio').click(function() {

            //The event fired, therefore the "New value(s)" (radio button value(s))  will be stored in the data sctructure
            var submitedRadios = [];

            //Geting the values from checked radio buttons
            $("form :radio:checked").each(function() {
                submitedRadios.push($(this).attr('value'));
            });

            //Now comparing both data structures
            if(dbRadios.compare(submitedRadios)){
                $('form :submit').fadeOut('slow');
            }else{
                $('form :submit').fadeIn('slow', function(){ ACTION! WILL BE EXECUTED MANY TIMES AS BUTTONS CLICKED});
            }

        });


        $("form").submit(function () {
        //AJAX GOES HERE!   
        alert("a submeter dados");  
        })

The compare function:

//Compare two different arrays
    Array.prototype.compare = function(testArr) {
        if (this.length != testArr.length) return false;
        for (var i = 0; i < testArr.length; i++) {
        if (this[i].compare) { 
            if (!this[i].compare(testArr[i])) return false;
        }
        if (this[i] !== testArr[i]) return false;
        }
        return true;
    }
  • 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-22T22:51:13+00:00Added an answer on May 22, 2026 at 10:51 pm

    It works great!

    //Attach onclick event to radio button(s)
            $('form :radio').click(function() {
                //Every new event clears the array so the new values can be stored properly
                submitedRadios = [];
                //Geting the values from checked radio buttons every time the state modifies
                $("form :radio:checked").each(function() {
                    submitedRadios.push($(this).attr('value'));
                });
    
                //Now comparing both data structures, if equal submit button hides, else shows
                if(dbRadios.compare(submitedRadios)){
                    $('form :submit').fadeOut('slow');
                }else{
                    $('form :submit').fadeIn('slow');
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form containing only select fields, a submit button and a reset
I have a form with a submit button. I want to disable the submit
I want to when entering in textarea imediately show me the submit button I
I want to show a chromeless modal window with a close button in the
...I want to Show the 'delete' button when user is an admin, and show
I want to show a message box when users trying to do any major
I have two pages I need, and want to show for the url /index
I want to pass a parameter, when i click submit button. urls.py urlpatterns =
I want the messagebox to only show if the number is equal to 0.
I have a simple form with email & password. I want to show 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.