I have an HTML table where I’m building an edit function to change a field inside this table.
I’d like your help to find a way to store the ID of the data listed in this field.
As a matter of fact, I have an object that has the listed data, RoleName, inside a <td>, and I’d like to store its id too, doing something like:
foreach ($accountUsers as $accountUser){
<td value="$accountUser->roleID">$accountUser->getRoleName()</td>
The problem is that value is not a property of a td. My constraint is that I must continue with the table.
If I’ve understood your question correctly, you can use HTML5
data-*attributes to store arbitrary data on an element:Update (see comments)
You can access this data via the jQuery
datamethod:Alternatively, you can use the native
getAttributemethod: