![]() |
Issue Grabing ID from form in a while loop using JQuery/AJax
I am having such a hard time with this.. 3 days stuck on something Im sure you the experts would laugh at.... so any help would be wonderful.
I have a php loop that loads a form for each row in a table. I want to approve a record and save it to a table. Problem is I cant seem to pull the unique ID of the form, it always adds the last row in the table.. I have tried $(this).attr("id"), $(this).form("id") and no dice. Please help a tired novice lol The Form Loop (php) Code:
while($row = mysql_fetch_array($pendingresult))Code:
|
id means "identity". What would you think if someone told you that you share your identity with others? You'd say: "No way, my identity is unique". And the same is true also for Javascript.
Bottom line: You should not use the same id attribute value on more than one element on the same page. Workaround: Prepend a unique String to the numeric identifier, like "article_101" and "cell_101". Then you can extract the numeric part using Code:
var numID = Number($(this).attr('id').match(/(\d+)/)[1]); |
Each form has a unique ID... $id = "myForm".$row['reg_id'];
thanks ok right? |
| All times are GMT +1. The time now is 05:06 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.