S
S
s_stepashka2020-03-03 16:01:29
Django
s_stepashka, 2020-03-03 16:01:29

Popup window on html page, how to pass data to it?

A table with records from the database is displayed on the page, and when you click on the "edit" link, a pop-up window appears with a form for editing this particular record. At the moment, the pop-up window appears, but in the fields "node number" and "joint number" the data of the FIRST record is always displayed, not the current one. Please tell me what is wrong?

{% extends "base.html" %}
{% block title %}Редактирование информации о линии{% endblock title %}
{% block leftcolumn %}<p><a href="/main_table">Возврат к рабочей таблице</a></p>{% endblock leftcolumn %}
{% block rightcolumn %}
                <form method="POST">
                    {% csrf_token %}
                            <p>
                                {% if full_lines_info_table.count > 0 %}
                                <h2>Информация по линии</h2>
                                <table border="">
                                    <tr><th>Id</th><th>Наименование линии</th><th>Узел</th><th>Стык</th><th>Сварщик</th></tr>
                                    {% for line1 in full_lines_info_table %}
                                        <tr><td align="center">{{ line1.id }}</td>
                                            <td>{{ line1.name_of_line }}</td>
                                            <td align="center">{{ line1.uzel_number }}</td>
                                            <td align="center">{{ line1.joint_number }}</td>
                                            <td align="center">{{ line1.welder }}</td>
                                            <td><a href="deletejoint/{{line1.id}}">Удалить</a>
                                                <p>
                                                <a href="#zatemnenie">Изменить</a></p>
                                                <div id="zatemnenie">
                                                    <div id="okno">
                                                        Изменение информации о стыке<br>
                                                        <form method="post" action="">
                                                            {% csrf_token %}
                                                            Добавить информацию: <p></p>
                                                            Название линии {{ form.edit_line_name }}
                                                            <input type="text" name="edit_line_name" required="" id="id_edit_line_name" value="{{line1.name_of_line}}">
                                                            Номер узла   {{ form.edit_uzel_number }} {{line1.id}}
                                                            <input type="text" name="edit_uzel_number" required="" id="id_edit_uzel_number" value="{{line1.uzel_number}}">
                                                            Номер стыка   {{ form.edit_joint_number }} {{line1.id}}
                                                            <input type="text" name="edit_joint_number" required="" id="id_edit_joint_number" value="{{line1.joint_number}}">
                                                            Сварщик   {{ form.edit_welder }}
                                                            <input type="text" name="edit_welder" required="" id="id_edit_welder" value="{{line1.welder}}">
                                                            <p><input type="submit" formaction="/applychanges" value="OK" >
                                                        </form>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                </table>
                                {% endif %}
                            <form method="post" action="">
                                {% csrf_token %}
                                Добавить информацию: <p></p>
                                Название линии  {{ form.inf_line_name }}
                                <input type="text" name="inf_line_name" required="" id="id_inf_line_name" value="{{full_lines_info_table.0.name_of_line}}">
                                Номер узла   {{ form.inf_uzel_number }}
                                <input type="text" name="inf_uzel_number" required="" id="id_inf_uzel_number">
                                Номер стыка   {{ form.inf_joint_number }}
                                <input type="text" name="inf_joint_number" required="" id="id_inf_joint_number">
                                Сварщик   {{ form.inf_welder }}
                                <input type="text" name="inf_welder" required="" id="id_inf_welder">
                                <p><input type="submit" value="OK" >
                            </form>
                            </p>
                </form>
{% endblock rightcolumn %}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Epikhin, 2020-03-03
@leshiple

Most likely you are opening a modal window referring to id="zatemnenie". You have a block with the same id in each line. Set a unique id. For example zatemnenie-1, zatemnenie-2, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question