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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:22:36+00:00 2026-05-25T13:22:36+00:00

I use the JQuery UI Library and the Dialog function. I would like to

  • 0

I use the JQuery UI Library and the Dialog function.

I would like to create more than one triggers inside my javascript.

This is my original JS:

$j(function() {
    $j( "#dialog1" ).dialog({
        autoOpen: false,
        show: "slide",
        hide: "explode"
    });
    $j( "#dialog2" ).dialog({
        autoOpen: false,
        show: "slide",
        hide: "explode"
    });
    ...

    $j( ".opener1" ).click(function() {
        $j( "#dialog1" ).dialog( "open" );
        return false;
    })
    $j( ".opener2" ).click(function() {
        $j( "#dialog2" ).dialog( "open" );
        return false;
    })
    ...
});

I need at least a dozen of those triggers. So, I though, let’s make a php While loop.
Something like this:

<?php
    $i = 1;
    while ($i <= 10) {
        echo '$j( "#dialog'.$i.'" ).dialog({
        autoOpen: false,
        show: "slide",
        hide: "explode"
        });';
    $i++;
    }

    $q = 1;
    while ($q <= 10) {
        echo '$j( ".opener'.$q.'" ).click(function() {
        $j( "#dialog1" ).dialog( "open" );
            return false;
        })';
    $q++;
    }?>

And for the first while, it’s all working just fine. It does the trick. But for the second while, the page just ignores the whole JS/PHP block…

What am I doing wrong?

  • 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-25T13:22:36+00:00Added an answer on May 25, 2026 at 1:22 pm

    This line in your second while loop:

    $j( "#dialog1" ).dialog( "open" );
    

    Should that not be:

    $j( "#dialog' . $q . '" ).dialog( "open" );
    

    At the moment all of your click handlers will open #dialog1 which I guess is not what you’re trying to do

    You could do the whole thing in js though as suggested above:

    for (var i=1;i<=10;i++) {
      $j('#dialog' + i).dialog({
        autoOpen: false,
        show: "slide",
        hide: "explode"
      });
    
      $j('.opener' + i).click(function() {
        $j( "#dialog" + i).dialog( "open" );
        return false;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web application and would like to use the jQuery library to
I'm trying to write a Greasemonkey script, and would like to use the jQuery
How would you convert following code to use only jquery library? <html> <head> <script>
I am trying to use the jQuery dialog UI library in order to position
I'm trying to use the simple modal jquery library on a page and the
If I'm alreadu using jquery library on site then should i use origional sifr
I'm alreadu using jquery library on site. What are pros and cons to use
I use jQuery to do AJAX calls. But specialchars like ÆØÅ (danish letter) comes
I use jquery post function to go to server and bring the link to
I use jQuery to fade in a caption on a icon mouseover. $(#v1).mouseover(function() {

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.