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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:35:03+00:00 2026-05-15T12:35:03+00:00

I am playing with the modal forms available with jQueryTools. I want to use

  • 0

I am playing with the modal forms available with jQueryTools. I want to use the modal forms on one of my pages, using the example provided here: http://flowplayer.org/tools/demos/overlay/modal-dialog.htm

I need to modify the example given above for the following reasons:

  1. My web page will have a dynamic number of forms on the page (the example uses a hard coded number of 2), and therefore is able to index into the array of triggers, using a hard coded index – I need to determine which trigger to close, based on the currently displayed form.

  2. I need to submit the form and obtain a JSON response from the server, and then use the response to update an element in the page.

This is what I have so far (based on the example). I have left out the CSS etc and the < head > section etc, for the sake of brevity. For my example, I have 3 buttons/forms, but these will be generated dynamically, so I need to find a generic way of determining which index to use to close the trigger:

<!-- the triggers -->
<p>
    <button class="modalInput" rel="#prompt1">User input1</button>
    <button class="modalInput" rel="#prompt2">User input2</button>
    <button class="modalInput" rel="#prompt3">User input3</button>
</p>


<div style="position: fixed; z-index: auto; top: 50.7px; left: 320px; display: none;" class="modal" id="prompt1">
    <div>This is form 1</div>
    <form>
        <input>
        <button type="submit"> OK </button>
        <button type="button" class="close"> Cancel </button>
    </form>
</div>

<div style="position: fixed; z-index: auto; top: 50.7px; left: 320px; display: none;" class="modal" id="prompt2">
    <div>This is form 2</div>
    <form>
        <input>
        <button type="submit"> OK </button>
        <button type="button" class="close"> Cancel </button>
    </form>
</div>

<div style="position: fixed; z-index: auto; top: 50.7px; left: 320px; display: none;" class="modal" id="prompt3">
    <div>This is form 3</div>
    <form>
        <input>
        <button type="submit"> OK </button>
        <button type="button" class="close"> Cancel </button>
    </form>
</div>    
<script>
$(document).ready(function() {

var triggers = $(".modalInput").overlay({

    // some mask tweaks suitable for modal dialogs
    mask: {
        color: '#ebecff',
        loadSpeed: 200,
        opacity: 0.9
    },

    closeOnClick: false
});

$("form").submit(function(e) {

    // close the overlay
    /* I need to determine the correct trigger index for the current form - but how ? */
    triggers.eq(UNKNOWN).overlay().close(); 

        //This is how I think to POST the form and receive JSON response (is this right?)
        $.post("test.php", $(this).serialize(),
                function(data){
                    alert(data);
                }, 'json'
              );
    // do not submit the form
    return e.preventDefault();
});

});
</script>
  • 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-15T12:35:03+00:00Added an answer on May 15, 2026 at 12:35 pm

    Use the jquery index(element) method..

     triggers.eq( $('form').index(this) ).overlay().close(); 
    

    this assumes that there is the same number of triggers and forms ..

    — about the form submit

    Your code is just fine except for minor hiccups
    serialize() is just fine, but you need to have names to your input boxes or they get ignored..
    (also you need to return false from the submit function)

    so

    $("form").submit(function(e) {
    
        // close the overlay
        /* I need to determine the correct trigger index for the current form - but how ? */
        triggers.eq( $('form').index(this) ).overlay().close();  
    
        //This is how I think to POST the form and receive JSON response (is this right?)
        $.post("test.php", $(this).serialize(),
                function(data){
                    alert(data);
                }, 'json'
              );
        // do not submit the form
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Playing with log4net, I have seen the possibility to use a per-thread stack of
I'm currently playing around with HTML_QuickForm for generating forms in PHP. It seems kind
When using System.Windows.Forms.ShowDialog(IWin32Window) , should I be able to pass in an IWin32Window representing
I'm playing with adding Gtk# GUI to a Windows.Forms application. I need a way
Just playing around with the now released Silverlight 2.0. I'm trying to put a
While playing around with regexps in Scala I wrote something like this: scala> val
I have been playing with the Ruby library shoes. Basically you can write a
I am playing with Microsoft's TreeView control and I am trying to force a
I'm playing with ASP.NET MVC for the last few days and was able to
I have been playing with this for a while, but the closest I have

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.