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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:05:47+00:00 2026-06-09T12:05:47+00:00

Actually there would be two questions, The scenario is The form contains three submit

  • 0

Actually there would be two questions,

The scenario is

The form contains three submit buttons, when i’m clicking one of those button the submit event is get triggered, then the first event is click but i’m not capturing this. The second event is form’s submit which is the one i’m capturing.

The code is

$('#search-main a').on('click', function(e){
    e.preventDefault();
    $('#search-advanced').remove();
    var target = $(this).attr('href');
    var res = $.get(target, function(data){
        $('body').append($(data).find('#search-advanced'));
        $('#search-advanced').addClass('row reveal-modal');
        $('#search-advanced')
        .css('top', 80)
        .css('border-radius' , '5px')
        .css('padding-left' , '0px')
        .css('padding-right' , '0px');

        $('#search-advanced').on('submit', 'form' ,function(e){
            var params = $('#search-advanced form').serialize();

            console.log(e);
            console.log(params);
            $.get(target, params, function(data){
                $('#search-advanced form').html($(data).find('#search-advanced form').html());
                $('#search-advanced input[name="select_filter"]').remove();
            });
            return false;
        });

        $('#search-advanced input[name="select_filter"]').remove();
        $('#search-advanced').on('change', '#categoryDropdown', function(){
            $('#search-advanced form').trigger('submit');
        });

        $('#search-advanced').append('<a class="close-reveal-modal">&#215;</a>');
        $('#search-advanced').reveal({
            animation: 'fade', 
            closeOnBackgroundClick: false
        });
    });
});

Since the JQuery documentation says

Only “successful controls” are serialized to the string. No submit
button value is serialized since the form was not submitted using a
button

I was unable to get the button values using serialize()

Question one is

How to get the button attributes which initiated the submit?

I approached in a different way as workaround of this, which was

  • First capturing the click event
  • Get the attributes
  • Pass the attributes as event extra parameters

The modified code is

$('#search-advanced').on('submit', 'form' ,function(e){
    var params = $('#search-advanced form').serialize();

    console.log(e.data);
    console.log(params);
    $.get(target, params, function(data){
        $('#search-advanced form').html($(data).find('#search-advanced form').html());
        $('#search-advanced input[name="select_filter"]').remove();

        if(typeof $('input[name="one_more"]') !== 'undefined'){
            var oldOneButton = $('input[name="one_more"]');
            var newOneButton = oldOneButton.clone();
            newOneButton.attr('type', 'button');
            newOneButton.insertBefore(oldOneButton);
            oldOneButton.remove();
        }

        if(typeof $('input[name="remove_filter"]').attr('name') !== 'undefined'){
            var oldRemoveButton = $('input[name="remove_filter"]');
            var newRemoveButton = oldRemoveButton.clone();
            newRemoveButton.attr('type', 'button');
            newRemoveButton.insertBefore(oldRemoveButton);
            oldRemoveButton.remove();
        }
    });
    return false;
});

$('#search-advanced input[name="select_filter"]').remove();
$('#search-advanced').on('change', '#categoryDropdown', function(){
    $('#search-advanced form').trigger('submit');
});

$('#search-advanced').on('click', 'input[name="one_more"]', function(){
    console.log($(this).attr('name'));
    var name = $(this).attr('name');
    var value = $(this).attr('value');
    $('#search-advanced form').trigger('submit', {name:value});
});

I changed the type attribute because it triggered the submit two times.

The problem is the console.log(e.data); prints undefined instead of the passed object.

Second question is

Why the e.data is undefined?

Any suggestions would be greatly appreciated.

  • 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-06-09T12:05:48+00:00Added an answer on June 9, 2026 at 12:05 pm

    To capture the button, fiddle

        $("#frm").on("click","button",function(){
           alert(this.id);
    
        }).on("submit",function(e){
            console.log("submit");
            return false;
        });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is actually two questions rolled into one. Is there a particular type of
Actually I have two questions. (1) Is there any reduction in processing power or
Actually there are two questions: is there a way to recursively pick up all
What I would like to do there is declaring class variables, but actually use
Is there a way to check weather a user actually clicked the like button
There are sort of two related questions here: A) How is enum implemented? For
This post is actually divided in two questions: Which kinds of associations classes/interfaces usually
Hi I'm getting strange feedback from the feedback sandbox server. Actually there should be
I have a general question about interpreters of functional languages: Are there actually any
There are actually 2 question i want to cover in this topic. 1) Is

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.