• 13

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Modal not detect id for each row in table

I have some problem.

I'm doing update and delete operation using php and bootstrap only. I'm currently stuck at update because only first row in table my modal detect the detail of id. on others row, my model does not detect and not appear the detail based on id selected.

This is my modal button, the delete is working but the update is not. It works for data at first row.


My modal process:


My Ajax:


I don't know why it is not working for different row in table.

Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]

You have ID "#edit" on each row. ID can only be used once. Please see Several elements with the same ID responding to one CSS ID selector

So you should remove the ID from the button, add a class to the button instead e.g. editMe so in your code you'd have class="btn btn-primary editMe"

Then update your jQuery to:

$(".editMe").click(function(){     //do your stuff here }); 

This should now work for every button as it's triggered by class (many buttons) rather than ID (first button only)

see demo
  • 24
Reply Report