getElementByID is going to have worse performance, but using it
wouldn't really affect your app, it's only used once to reference the
object.
Is your select really 2400 options long? It seems to me that
you might want to consider going at the problem differently if so. No
one is going to scroll through 2400 options to find something...

Why is it necessary to have two queries populate the select
and the list of friends in the first place though? It sounds like to
me they contain the same data.

-- 
jon

Tuesday, June 18, 2002, 8:57:51 PM, you wrote:
RMJ> I knew the CurrentRow was a bad idea.  It was in there for a quick demo to
RMJ> the boss.  :)

RMJ> I ended up doing the loop like shown, but I didn't use the getElementsByID()
RMJ> method.  I have 2400+ records in the Friends table and it takes almost 3
RMJ> seconds to process the list looking for the match.  Does the
RMJ> getElementsByID() method result in better performance?

RMJ> Russel

RMJ> -----Original Message-----
RMJ> From: Jon Hall [mailto:[EMAIL PROTECTED]]
RMJ> Sent: Tuesday, June 18, 2002 7:24 PM
RMJ> To: CF-Community
RMJ> Subject: Re: Javascript brain lock....


RMJ> First don't use the currentrow variable, that's what the main problem is.
RMJ> Use something that you can use to relate the two lists, like the record ID
RMJ> field in the database, and use that in the function call and in the option
RMJ> id. Then loop through the select box looking for the correct id.
RMJ> Something like this...

RMJ> <script language="JavaScript">
RMJ> function sf(fid) {
RMJ>  obj = document.getElementById('intFriends');
RMJ>  for (i = 0; i != friends.length; i++) {
RMJ>   if (obj.options[i].id == fid)
RMJ>    obj.selectedIndex = i;
RMJ>  }
RMJ> }
RMJ> </script>


RMJ> ----- Original Message -----
RMJ> From: "Russel Madere" <[EMAIL PROTECTED]>
RMJ> To: "CF-Community" <[EMAIL PROTECTED]>
RMJ> Sent: Tuesday, June 18, 2002 1:43 PM
RMJ> Subject: Javascript brain lock....


>> Hi all,
>>
>> Here is a quick question for the DHTML folks in the list.  I have an HTML
RMJ> table with a list of friends and a select box on the same page with the same
RMJ> list.  I need to click on the name of a friend and cause the same item in
RMJ> the select box to be selected.  I can currently using:
>>
>>     function SelectFriend(SelectedOption) {
>>         obj = document.form.FriendsForm.intFriends;
>>         obj.selectedIndex = SelectedOption;
>>
>> With the call to the function looking like:
>>
>>     javascript:SelectFriend(#CurrentRow#)
>>
>> This works fine as long as the 2 queries generating the list and the
RMJ> select box are the same.  However, if I sort the list of friends, the
RMJ> indexes no longer match.  How can I pass my function a FriendID (the value
RMJ> of the options in the select box) and have it find the index to select?
>>
>> My call neds to look like:
>>
>>     javascript:SelectFriend(#FriendID#)
>>



RMJ> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to