Hi all,
I've got a table to which I'm adding rows. (this site is targeted to mainly IE7). I'm using the DOM cloneNode on an existing row, then the appendChild method to append it to the table's body object.
Now, when the table is first loaded, an asp page loops through a database and builds a row for each record, with an input element inside the td element. Then the user clicks a button to add a row, and it's important for me to know which row the mouse was last clicked on.
So my current method of knowing which row is clicked on is hardcoding the onclick event of the input element as:
...where g_currentRow is a global variable, and 5 is the row number. This works just fine...I test it with a button that just displays the variable g_currentRow correctly.
However, for the new rows, prior to me appending the row, I do the following:
...where strnewrow is a variable holding the incremented row number. This does not work, yet if I display the rendered html after the appendRow, the new row is there and so is the onclick event, exactly as the pre-existing rows.
Now, I've seen the syntax:
tnewrow.onclick=someFunction
...but I can't figure out how to put an argment in that function because setting it that way is not accepting "someFuncion" (or any script for that matter) as a *string* for which I can parse in variable values.
Can anyone tell me how I would assign a function to an event where that function takes arguments? Thanks,
--Jim
I've got a table to which I'm adding rows. (this site is targeted to mainly IE7). I'm using the DOM cloneNode on an existing row, then the appendChild method to append it to the table's body object.
Now, when the table is first loaded, an asp page loops through a database and builds a row for each record, with an input element inside the td element. Then the user clicks a button to add a row, and it's important for me to know which row the mouse was last clicked on.
So my current method of knowing which row is clicked on is hardcoding the onclick event of the input element as:
Code:
onclick="g_currentRow='5';"
However, for the new rows, prior to me appending the row, I do the following:
Code:
tnewrow.setAttribute('onclick',"g_currentRow=\'" + strnewrow + "\';")
Now, I've seen the syntax:
tnewrow.onclick=someFunction
...but I can't figure out how to put an argment in that function because setting it that way is not accepting "someFuncion" (or any script for that matter) as a *string* for which I can parse in variable values.
Can anyone tell me how I would assign a function to an event where that function takes arguments? Thanks,
--Jim