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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:07:57+00:00 2026-05-28T13:07:57+00:00

I have a Question regarding Jquery ui dialog boxes. What i have/i did: I

  • 0

I have a Question regarding Jquery ui dialog boxes.

What i have/i did: I have multiple forms(depending upon the result returned from mysql result). the forms looks like this:

<form action="?" method="POST" id="form1">

    <input type="text" name="title"/>

     .................................
      other inputs
     .................................

     <input type="submit" class="delete" id="delete" name="delete" value="delete"/>

</form>

the same form but only with id of the form as ‘form2’, or depending on the query (form3, form4 etc….)

jquery codes

$(document).ready(function(){

                var $dialog = $('<div></div>').html('<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Do you really want to delete it?')

                .dialog({

                            autoOpen:false,

                            resizable: false,

                            height:140,

                            modal: true,

                            title:'Confirm delete',

                            buttons: {

                                "Yes": function(){

                                *********************************       
                                document.forms["form1"].submit();
                                *********************************

                                $(this).dialog("close");   

                                },

                                "No": function(){

                                    $(this).dialog("close");

                                }

                            }

                });

                $('#delete').click(function(){

                            $dialog.dialog('open');

                            return false;

                });

    });

What i want to achieve?
I want to trigger the submit action for only the form in which the delete button is in. What i meant is, if user clicks the delete button on form1, then only form1 should be submitted. I have highlighted one line in Jquery code with stars. on that particullar line, when the user clicks the delete button, the id of the corresponding form or form index should retrieved (to which the delete button belongs) and submit only that particular form.

the problem i am facing:
i can hardcode the form ids but there is no way i can exactly know the number of form as it depends on the search term. So i am trying to retrieve it dynamically. is it possible?

p.s. on the delete button click event, if i select $(‘#delete’), it’l work for only one form. If i use $(‘.delete’), it is submitting all forms or may be over writing? (i guess because on doing var_dump($_POST) it is returning an empty array)

Any help would be appreciated. and if more information needed, i can provide.

  • 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-28T13:07:57+00:00Added an answer on May 28, 2026 at 1:07 pm

    @itachi

    you can’t give same id to multiple elememts.
    change your code as below

    $('.delete').click(function(e){
        e.preventDefault();  
        currentForm = $(this).parent('form').get(0);
        $dialog.dialog('open');
        return false;
    });
    

    and

    buttons: {
    
        "Yes": function(){
            if(currentForm){
                currentForm.submit();
            }
            $(this).dialog("close");   
        },
        "No": function(){
            $(this).dialog("close");
        }
    }
    

    you can view running demo here

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

Sidebar

Related Questions

I have a question regarding jQuery. I have multiple images that are, in essence,
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
i have a question regarding Jquery <select id=thechoices> <option value=0>Select Box</option> <option value=box1>Box 1</option>
I have a basic question regarding jQuery. I have a static time-selection box IE:
I have a question regarding CSS3 Gradients and a plugin for jQuery called color
Have a question regarding URL and jQuery. Can I specify URL to tell jQuery
I have somewhat of a thought question regarding jQuery Ajax. My question is this:
I have one question regarding using JQuery UI tab control in the asp.net mvc
I'm using the hoverIntent Jquery plugin and I have a question regarding callback functions.
I've got a question regarding jQuery, I want to remove the following from 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.