I'm trying to capture the row ID of a table when a user makes a change to the value of a form element. The row id is set to the the unique ID from the database table.
(Eventually I want to append each row ID to the value of a hidden form field that will be processed server-side so that only the necessary rows are updated)
Here is the code I'm using:
I always get an error message saying TR is undefined, which I don't quite understand since I am trying reference a standard HTML element. But this is the first time I have tried using getAttribute, so I'm sure I'm missing something simple!
(Eventually I want to append each row ID to the value of a hidden form field that will be processed server-side so that only the necessary rows are updated)
Here is the code I'm using:
Code:
<script type="text/javascript">
var idList;
function initalise(){ //called with onLoad of body
idList = document.getElementById("txtList");
idList.setAttribute('value',''); //set initial value to empty string
}
function setListValues(){ // called with onChange of each form field
idList.setAttribute('value', TR.getAttribute('id')); //error message points to this line
}
</script>
I always get an error message saying TR is undefined, which I don't quite understand since I am trying reference a standard HTML element. But this is the first time I have tried using getAttribute, so I'm sure I'm missing something simple!