Say for example that I've got:
What I want to happen is that when I mouse over the first or second item in list one, the corresponding item in the second list is highlighted as well (they map directly, so the 4th item in the first list would map to the 4th item in the second etc...).
I can think of (several ways to do this:
1. Use the id's; create a function that accepts the hovered list item as a parameter, use getElementById to locate the second item and the set it's style or css class. The problem I see with this method is that the id's I used above are just for show and will be different in the production version, so I'd probably have to write a function and hard code all the "mapped" id's. I want to avoid this if possible.
2. Loop through the elements; create a function that accepted the list item as a parameter, find it's position in the list and then get a reference to the relevant item in the second list, based on the position found. The problem I see here is whether speed would be an issue or not if the user mouses over the items quickly. I'm also not sure how I'd handle which list item was actually hovered over in the first list.
Can anyone think of an easier or better way to do this (I'd prefer a method which wasn't restrictive so that if the lists grow, my js code will accommodate this)? Any examples?
Thanks,
-------------------------------------------------------
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
Code:
<ol id="listone">
<li id="one_one">1</li>
<li id="one_two">2</li>
</ol>
<ol id="listtwo">
<li id="two_one">1</li>
<li id="two_one">2</li>
</ol>
What I want to happen is that when I mouse over the first or second item in list one, the corresponding item in the second list is highlighted as well (they map directly, so the 4th item in the first list would map to the 4th item in the second etc...).
I can think of (several ways to do this:
1. Use the id's; create a function that accepts the hovered list item as a parameter, use getElementById to locate the second item and the set it's style or css class. The problem I see with this method is that the id's I used above are just for show and will be different in the production version, so I'd probably have to write a function and hard code all the "mapped" id's. I want to avoid this if possible.
2. Loop through the elements; create a function that accepted the list item as a parameter, find it's position in the list and then get a reference to the relevant item in the second list, based on the position found. The problem I see here is whether speed would be an issue or not if the user mouses over the items quickly. I'm also not sure how I'd handle which list item was actually hovered over in the first list.
Can anyone think of an easier or better way to do this (I'd prefer a method which wasn't restrictive so that if the lists grow, my js code will accommodate this)? Any examples?
Thanks,
-------------------------------------------------------
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]