-
Okay... I have a series of document objects
Code:
<table>
<tr id='objRow'></tr>
<tr id='objRow'></tr>
<tr id='objRow'></tr>
<tr id='objAnotherRow'></tr>
<tr id='objAnotherRow'></tr>
<tr id='objAnotherRow'></tr>
<tr id='objDifferentRow'></tr>
<tr id='objDifferentRow'></tr>
<tr id='objDifferentRow'></tr>
</table>
I have some onClick events that pass the name of one of these objects. Let's say I want to make them hide.
Code:
<script language=JavaScript>
function hide(x) {
for (var i = 0; i < x.length; i++) {
x\[i\].style.display = "none";
}
}
</script>
Well, it is looking for an object called x. I want to anonymously refer to the object, using x. How can I do this?
-
ok, i am not sure if this is what you want, but here goes:
when you have the onclick, you can tell the function what called it by sending it "this".
for example:
Code:
onClick="whateverFunction(this)"
I hope this helps.
-
Well...
I have this, perhaps this is wrong.
Code:
<a href='javascript:void()' id='objRow' onclick='ToggleDisplay(this)'>Click Me!</a>
I used to not have an id on that, just having the name objRow as the ToggleDisplay() param. But with the above, I'm getting javascript:void() in the function.
Anyway, I bought the Rhino book last night. I'll see what I can learn.
-
Whoohooo, Success!
I got it to work. For the longest time I was using quotes in the function call, thinking I had to pass the name of the rows to be affected. I wanted a way to get at x's value, not use x. When I left out the quotes it passed a reference to the object with that name. x was now a reference to the rows to be affected.
It was a very very very simple problem.