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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:05:16+00:00 2026-06-11T22:05:16+00:00

I’m trying to add a jQuery dialog in each row of a table, using

  • 0

I’m trying to add a jQuery dialog in each row of a table, using jQuery, and dataTables plugin.
I want to add in the dialog data specific to each row.
I’ve seen in other post that you can think of two ways:
1) One dialog for each row.
2) Only one dialog for all the rows, and then fill it with specific data.

In this example, I have a list of courses in a table, with name(nombre), code(codigo), and mode(modo).
For each row, there is a button (modificar) that should show a dialog to edit the data for that course. Of course, in each dialog, must be loaded the data of that row.

My idea (viewed other ideas in other post) is to put the dialog inside the row, so I can load the data from that row.

I created a class (masInfo) and in the Javascript code, I put a function that should open the dialog after the button is. But it doesn’t work.

Do you have any idea? Thanks.

HTML Y JSP

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link type="text/css"
                href="css/milk.css" rel="stylesheet" />
    <title>Paginadores tablas</title>
    </head>
    <body>
        <%
            CatalogoCursos catalogoCursos = CatalogoCursos.getCatalogoCursos();
            ArrayList<Curso> cursos = catalogoCursos.getCursos();
        %>
        <div id="miTabla">
            <form id="formulario" name="formulario" method="post">
                <table id="tabla">
                    <thead>
                        <tr>
                            <th>Nombre </th>
                            <th>Código </th>
                            <th>Modo de juego </th>
                            <th> Acción </th>
                        </tr>
                    </thead>
                    <tbody>
                    <%
                        for(Curso curso: cursos) {
                    %>
                        <tr>
                            <td><%=curso.getNombre()%></td>
                            <td><%=curso.getCodigo()%></td>
                            <td><%=curso.getStringModo()%></td>
                            <td> 
                                <input type="button" class="masInfo" value="modificar"/>
                                <div title="Modificar curso">
                                    <table>
                                        <tr>
                                            <td><input type="text" name="mod_nombre" value="<%=curso.getNombre()%>"/></td>
                                            <td><input type="text" name="mod_codigo" value="<%=curso.getCodigo()%>"/></td>
                                            <td><input type="text" name="mod_modo" value="<%=curso.getStringModo()%>"/></td>
                                        </tr>
                                    </table>
                                </div> 
                            </td>
                            </td>
                        </tr>
                    <%
                        }
                    %>
                    </tbody>
                </table>
            </form>
        </div>

    </body>
    </html>

JAVASCRIPT

<script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery-ui.custom.js"></script>
    <script type="text/javascript" src="js/jquery.dataTables.js"></script>
    <script type="text/javascript">
    (function($) {
        // Dialog
        $('.masInfo').next().dialog({
            autoOpen: false,
            width: 600,
            buttons: {
                "Borrar": function() {
                    document.formulario.submit();
                    $(this).dialog("close");
                },
                "Cancelar": function() {
                    $(this).dialog("close");
                }
            }
        });

        // Dialog Link
        $('.masInfo').click(function(){
            $('#dialog').dialog('open');
            return false;
        });
    });
  • 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-11T22:05:17+00:00Added an answer on June 11, 2026 at 10:05 pm

    You are much better off using just one dialog and populate the relevant information in the dialog on the button click. The way you currently do it will result in a lot of duplicated input elements.

    So, the HTML would look like:

    <div id="miTabla">
        <table id="tabla">
            <thead>
                <tr>
                    <th>Nombre </th>
                    <th>Código </th>
                    <th>Modo de juego </th>
                    <th> Acción </th>
                </tr>
            </thead>
            <tbody>
            <%
                for(Curso curso: cursos) {
            %>
                <tr>
                    <td><%=curso.getNombre()%></td>
                    <td><%=curso.getCodigo()%></td>
                    <td><%=curso.getStringModo()%></td>
                    <td> 
                        <input type="button" class="masInfo" value="modificar"/>
                    </td>
                    </td>
                </tr>
            <%
                }
            %>
            </tbody>
        </table>
    </div>
    <div title="Modificar curso" id="ModificarDialog">
        <form id="formulario" name="formulario" method="post">
            <table>
                <tr>
                    <td><input type="text" name="mod_nombre" id="mod_nombre" /></td>
                    <td><input type="text" name="mod_codigo" id="mod_codigo" /></td>
                    <td><input type="text" name="mod_modo" id="mod_modo" /></td>
                </tr>
            </table>
        </form>
    </div> 
    ​​​
    

    JavaScript would change to:

    (function($) {
        // Dialog
        $('#ModificarDialog').dialog({
            autoOpen: false,
            width: 600,
            buttons: {
                "Borrar": function() {
                    document.formulario.submit();
                    $(this).dialog("close");
                },
                "Cancelar": function() {
                    $(this).dialog("close");
                }
            }
        });
    
        // Dialog Link
        $('.masInfo').click(function(){
            var cells = $(this).parent().find('td');
            $('#mod_monbre').val(cells.eq(0).text());
            $('#mod_codigo').val(cells.eq(1).text());
            $('#mod_modo').val(cells.eq(2).text());
            $('#dialog').dialog('open');
            return false;
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am reading a book about Javascript and jQuery and using one of the
I want to construct a data frame in an Rcpp function, but when I
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:

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.