Table featuring identical submit buttons in each row: initial submit button is nonfunctional (potential issue with multiple identical IDs)

My table displays product files, with the option to add notes. If a note is added, it shows in a row. If not, a text area field with a submit button appears instead.

Everything seems to be working well, except for the first row without a note. After adding a note and clicking the submit button, nothing happens.

HTML:

<div id="files-list" style="display: none">
        <table class="table">
            <thead>
                <tr>
                    <th>File</th>
                    <th>Date</th>
                    <th>Notes</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <c:if test="${fn:length(bean.product.files)>0}"> 
                <c:forEach items="${bean.product.files}" var="na">
                    <tr>
                        <td><a href="${pageContext.request.contextPath}/products/files/${na.id}.do">${na.name}</a></td>
                        <td><fmt:formatDate value="${na.created}" pattern="yyyy-MM-dd HH:mm" /></td>
                        <td>
                            <c:if test="${empty na.note}">
                                <form:form id="${na.id}" method= "POST" modelAttribute="bean" action="${pageContext.request.contextPath}/app/updateFile.ajax?id=${bean.product.id}&fileId=${na.id}" style="display: inline">                             
                                    <form:textarea path="prodFiles" rows="1" cols="50" />
                                    <input type="hidden" name="version" value="${bean.product.version}">
                                    <input type="submit" id="submitButton" value="Save it!" />
                                </form:form>    
                            </c:if>
                            <c:if test="${not empty na.note}">
                                <div style="max-width: 400px">${na.note}</div>                          
                            </c:if>
                        </td>
                        <td><button type="button" class="btn btn-xs btn-danger" onclick="$().mkdelformTable('${pageContext.request.contextPath}/app/deleteFile.ajax?id=${bean.product.id}&fileId=${na.id}', this)">Delete it!</button></td>
                    </tr>
              </c:forEach>
             </c:if>
           </tbody>
        </table>
    </div>

Possible insights:

  1. Upon opening the table (as a pop-up), the console indicates multiple
    [DOM] Found X elements with non-unique id
    errors
  2. Inspecting elements in developer tools revealed that the first row lacks the form part, which might be related to the issue of duplicated IDs. Example:
<td>                                                                
   <textarea id="prodFiles" name="prodFiles" rows="1" cols="50"></textarea>
   <input type="hidden" name="version" value="181">
   <input type="submit" id="submitButton" value="Save it!">
</td>

VS

<td>                            
   <form id="65" style="display: inline" action="/oferty/app/updateFile.ajax?id=12701&amp;fileId=65" method="POST">                             
      <textarea id="prodFiles" name="prodFiles" rows="1" cols="50"></textarea>
      <input type="hidden" name="version" value="181">
      <input type="submit" id="submitButton" value="Save it!">
   </form>  
</td>


Edit: Keep in mind that new files can always be added, so hard-coding different names or IDs is not a viable solution if suggested.

Answer №1

After discovering some legacy code, I successfully resolved issues related to 'multiple same ids' by implementing a pop-up notification on the previous page instead of using an input field. Additionally, I replaced it with a button that directs users to the new pop-up.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to halt animation at the final frame

I'm attempting to implement a character jumping animation that should stop on the last frame, but it's not working as expected. I have tried using animation-fill-mode: forwards; but it didn't produce the desired outcome. Below is the c ...

Erase jQuery from the text

I am struggling with splitting or removing text from a filename. For example, if I have filenames like: 200726100_50-0002.JPG 230514008_60-0001.JPG The desired result should be: 230514008_60.JPG 200726100_50.JPG Am I not using the split function cor ...

Footer that is adhered to the bottom of the page with a

Can a sticky footer with a transparent background be achieved without a content background (.wrapper) underneath it? I found this resource: ...

Angular List Selector: A versatile multiple selection component with a stylish list design

I'm in need of a select component similar to the one shown in The issue is that Material Angular doesn't have this specific component, so I opted to use the default HTML select inside my component. Everything was working fine until I tried to de ...

Caution: React is unable to identify the `PaperComponent` prop on a DOM element

Trying to create a draggable modal using Material UI's 'Modal' component. I want users to be able to move the modal around by dragging it, so I decided to use 'Draggable' from react-draggable library. However, I encountered this er ...

HTML/CSS - Enhances user experience by zooming in on select tag when tapped on mobile devices

I am experiencing an issue with a select menu on mobile devices. Whenever I tap on the menu, it seems to zoom in slightly. Is there a particular -webkit property causing this behavior? How can I prevent the screen from zooming when I tap on the select me ...

The footer is supposed to be at the bottom, but unfortunately, the clear float isn

Today seems to be a rough one without enough coffee, as I'm struggling to remember how to do this I am trying to achieve the following layout: header content float float footer The content section contains two floating elements. The problem is ...

Issues with utilizing jQuery AJAX for form submissions

I am currently customizing a webpage to fit the specific requirements of a client using a template. The page contains two contact forms which are being validated and sent to a PHP file via AJAX. One of the forms is standard, while the other one has been mo ...

What is the best way to activate a JQ function with my submit button?

Is there a way to trigger a JQ function when clicking the submit button in a form? I managed to make Dreamweaver initiate an entire JS file, but not a particular function. ...

The ball refuses to fall into the designated boxes

I designed a basic webpage featuring 3 boxes that, when clicked on, trigger the dropping of a ball into them. Below is the code I used: <!DOCTYPE html> <html> <head> <script type="text/javascript"> function popup (n) { ...

Utilizing the predefined color palette of Bootstrap for styling text in a

When creating a form using Bootstrap, I want to add some text in a color that matches the brand color used for buttons. While I am aware of the text colors like text-primary available in Bootstrap, I prefer to use button colors for my text. I attempted th ...

Is there a requirement to download and set up any software in order to utilize Highchart?

I've been working on a project to create a program that displays highcharts, but all I'm getting is a blank page. Here's my code: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charse ...

How to instantly return progress bar to zero in bootstrap without any animations

I am currently working on a task that involves multiple actions, and I have implemented a bootstrap progress bar to visually represent the progress of each action. However, after completion of an action, the progress bar is reset to zero using the followi ...

Displaying PHP errors in input fields

I have noticed that this particular code is functioning correctly. However, I am wondering why I receive an error when I remove the foreach loop ($rows as $row). Is there a method to display the data without utilizing it? <?php require("coneccion.php ...

How to add a background image in CSS with HTML's help

I am a beginner learning HTML and CSS, attempting to incorporate a Full Screen Background Image using CSS. Unfortunately, the code I have written is not working as expected despite following various tutorials. Below is my code: HTML file <!DOCTYPE htm ...

hide input type with minimal display

Can someone help me find the less equivalent to this css code snippet? I'm not familiar with less and this code is part of a larger global css file that includes generated code from all less files. input[type="checkbox"] { display: none; } Any a ...

Is it achievable through CSS alone to eliminate the bullet point in a UL list when it consists of just a single item?

Is it feasible to achieve a solution using CSS alone that remains functional even on IE8, ensuring the following criteria: If a <ul> list contains 2 or more items, then maintain the bullets in front of each item as per usual. When there is only one ...

Adjusting the alignment of a facial image on Canvas by selecting specific click-points

I have a unique idea for an app that allows users to correct a tilted face with just 2 clicks The concept is simple - users click on the middle of the nose and the middle of the eyebrows within the image to generate two points: eyebrowMiddle(x1,y1) and no ...

Preventing selection of past dates with Material UI in ReactJS

I'm currently working on a date range picker using react material ui. The goal is to allow users to select a specific date and then disable all past dates from that selected date onward. How can I go about implementing this functionality in react mate ...

Tips for adjusting the scrollbar in Tailwind (next.js/react)

Having trouble changing the appearance of my scrollbar in a single page application using Tailwind (react/next). I've attempted to create custom CSS for the first div in my index file, like so: <div className="no-scroll"> <<< ...