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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:41:44+00:00 2026-05-23T04:41:44+00:00

I have a user input page which loads different forms with ajax depending on

  • 0

I have a user input page which loads different forms with ajax depending on some options the user has. I want to save this forms data with AJAX as well, but it only works with the first form that is loaded. Once the user changes the options, and a different form is loaded, the change of the form behaviour applied with jQuery no longer works.

I guess this is happening because the script is applying the new behaviour to the form that is currently on the page, but not to forms that are loaded later, right?

I already tried encapsulating the $(‘form’).submit()… etc in a function and calling it everytime a new form is loaded, but it doesnt work either…

Then, how can i solve this? This is my code (some of it):

function showFormUpdate(month, show) {
    //actualiza el formulario por ajax
    $('#showFormWrapper').fadeOut();

    $.post("../inc/ajax-select-show.php", {month: month, show: show}, function(data){
                    $('#showFormWrapper').html(data);
                    whatIsActive ();
                    }); 
    $('#showFormWrapper').fadeIn();             
    }

function showFormsend () {
    $.post("../inc/ajax-saveshowform.php", 
        {
        activeShow: $('input#activeShow').val(),
        activeMonth: $('input#activeMonth').val(),
        everyday: $('input#everyday').val(),
        mon: $('input#mon').val(),
        tue: $('input#tue').val(),
        wed: $('input#wed').val(),
        thu: $('input#thu').val(),
        fri: $('input#fri').val(),
        sat: $('input#sat').val(),
        sun: $('input#sun').val()
        }, function(data){
            alert (data);           
                    }); 
}

$(document).ready(function() {

    $('a.changeForm').click(function(event){
        event.preventDefault(); 
        if ($(event.target).hasClass('changeShow')){
            showFormUpdate($('input[name="activeMonth"]').val(), $(event.target).attr('show'));
            }
        if ($(event.target).hasClass('changeMonth')){
            showFormUpdate($(event.target).attr('month'), $('input[name="activeShow"]').val());
            }   
        });

    //this is the part that changes the functionality of the form,
    //but only works with the first loaded form
    $('.showForm').submit(function(event){          
        showFormsend ();    
        return false;           


        })
});
  • 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-23T04:41:44+00:00Added an answer on May 23, 2026 at 4:41 am

    You might have to use the live function with your events. When you destroy/re-add items that matched a raw event function when jQuery loaded (like .click or .submit) their events are gone once they are removed.

    To get around this use .live which will apply the event to all existing and future-added elements that match your selector:

    $('a.changeForm').live('click', function(event){
    
    $('.showForm').live('submit', function(event){   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input field on my page where the user will type in
I have a form on a page where the user has inputs to edit
On a website if I have a form where the user can input some
I have a script that calls an application that requires user input, e.g. run
I have to make column charts in Excel using VBA only (no user input).
How do I have a Python script that can accept user input and how
How can I validate the user input by using scanf. Right now I have
I have made a little app for signing up for an event. User input
I have a situation where I have to take input from the user using
I have a file input element that needs to be cloned after the user

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.