I knew the CurrentRow was a bad idea.  It was in there for a quick demo to
the boss.  :)

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

Russel

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


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

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


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


> Hi all,
>
> Here is a quick question for the DHTML folks in the list.  I have an HTML
table with a list of friends and a select box on the same page with the same
list.  I need to click on the name of a friend and cause the same item in
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
select box are the same.  However, if I sort the list of friends, the
indexes no longer match.  How can I pass my function a FriendID (the value
of the options in the select box) and have it find the index to select?
>
> My call neds to look like:
>
>     javascript:SelectFriend(#FriendID#)
>



______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

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

Reply via email to