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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:55:23+00:00 2026-05-26T08:55:23+00:00

I have an image next to each radio button on a form. The number

  • 0

I have an image next to each radio button on a form. The number and content of radio buttons are fetched from a database. I’m trying to create a click event on those images, which provides a quick intro about the respective option.

$('#icon').click(function() {
    $('#dynamicid').dialog();
    return false;
});

I know how to create a dialog on click, but not how to create it from div whose id and content are fetched from DB using php. How can I do that?

P.S: I’m new to jQuery.

  • 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-26T08:55:24+00:00Added an answer on May 26, 2026 at 8:55 am

    A lot of this depends on the surrounding factors. Like where exactly the dialog divs come from.

    Let’s assume for a moment that regardless of other markup, you have your image to be clicked, and your dialog div is the next sibling in the markup:

    <div id="wrapper">
      <input type="radio"> <!-- simplified; I didn't look up the actual markup syntax -->
      <img src="foo" class="clicky"/>
      <div class="dialog">This is the related dialog</div>
    
      <input type="radio"> <!-- simplified; I didn't look up the actual markup syntax -->
      <img src="bar" class="clicky"/>
      <div class="dialog">This is related to the previous image</div>
    </div>
    <div id="myDialog"></div> <!-- a container that can be reused; put it right before the body tag closes -->
    

    You hide the dialog divs because you don’t need them visible until the click:

    .dialog, #myDialog { display: none; }
    

    Then you delegate or otherwise bind a click to this type of image. I like delegate:

    $('#wrapper').delegate('img.clicky', 'click', function() {
      var theContent = $(this).next().html();
      $('#myDialog').html(theContent).dialog();
    });
    

    It’s that simple. The wrapper is listening for the click (this can be any ancestor that’s going to contain your clickable images), click is heard on the image (which is “this”). We use jQuery to traverse to the next sibling (the dialog div), add its contents to our container div, and call dialog() on it.

    Updated fiddle: http://jsfiddle.net/txugb/3/

    (Note that although jQuery UI is included, its CSS is not; the dialog won’t look right but it will appear.)

    [update:]
    In response to possible layout concerns with the way I proposed, I modified the function to reuse a single dialog container.

    It occured to me after the poster’s comment that the initial suggestion might have been flawed all along. When jQuery UI hides the dialog, I believe it appends it to the body tag.

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

Sidebar

Related Questions

I have CheckedListBox, now i want to put image from the ImageList next to
I'd like to have an image next to the text on each row of
I want to have Buttons next to each other on the same line, and
I have a table list of companies with a [+] button next to each
I have two images next to each other in HTML. One image is taller
I have a directory with a number of images. Each image is in the
I have an Edit button next to each uploaded thumbnail on my page that
I am writing an MVC3 page, and I have images with radio buttons next
I'm trying to get the first image from each of my posts. This code
I have a sprite sheet and I want to display images next to each

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.