|
-
Mar 28th, 2001, 03:36 PM
#1
Thread Starter
Frenzied Member
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?
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Mar 28th, 2001, 07:59 PM
#2
PowerPoster
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.
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Mar 29th, 2001, 11:01 AM
#3
Thread Starter
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Mar 29th, 2001, 11:20 AM
#4
Thread Starter
Frenzied Member
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.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|