I have javascript code like this:
<tr id='$stavkaid'>
<td class='nonEditableData'>$naziv</td>
<td contenteditable='true' class='editableData' onkeypress='return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13 || event.charCode == 46) ? null : event.charCode >= 48 && event.charCode <= 57' onblur='if(innerHTML.length <= 0) { innerHTML = 0 }else{ innerHTML = innerHTML, checkInput(parentNode.id)}'>$kolicina</td>
<td contenteditable='true' class='editableData' onkeypress='return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13 || event.charCode == 46) ? null : event.charCode >= 48 && event.charCode <= 57' onblur='if(innerHTML.length <= 0) { innerHTML = 0 }else{ innerHTML = innerHTML, checkInput(parentNode.id)}'>$pcbp</td>
<td contenteditable='true' class='editableData' onkeypress='return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13 || event.charCode == 46) ? null : event.charCode >= 48 && event.charCode <= 57' onblur='if(innerHTML.length <= 0) { innerHTML = 0 }else{ innerHTML = innerHTML, checkInput(parentNode.id)}'>$rabat</td>
<td class='nonEditableData'>$pcsp</td>
<td class='nonEditableData'>$pvsp</td>
</tr>
As you can see inside 3 td
i run javascript function checkInput(parentNode.id)
Function looks like this:
function checkInput(stavkaID)
{
alert(stavkaID);
}
And it works like charm but now what i want is to somehow get values of each row tr
where stavkaID
is selected one.
So how it went in my head is to somehow inside function i do something like this
function checkInput(stavkaID)
{
var naziv = getElementById(stavkaID).nowSomehowIdentifyTDWithValueFor(naziv).innerHTML;
//And like this for other 5 variables
}
I know i can loop through each element of tr
with this but problem is identifying td
my loop is currently at.
I cannot set id for td
since it will be static and next time i create tr
it will have same id which is not possible.