|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
[PLUG] OT: Javascript question
|
Not sure where to go with this... it's not really liunx although I'm
developing it on a Linux system :-)
I'm writing some client-side Javascript to allow the user to select
between an undetermined number of choices that I build in a list
dynamically. There are two loops. First is a loop that creates the
links and that works fine. The second is a loop that is supposed to
create and bind an anonymous function to the click event of each of the
links created in the first loop. (it has to be done in two loops
because you cannot bind event handlers to DOM elements that don't exist
yet.)
Unfortunately, I get the last function for all links; Here is the loop:
for ( var loop2 = 0; loop2 < count ; loop2++ ) {
var vehID =
doc.getElementsByTagName("id")[loop2].childNodes[0].nodeValue ;
var loadURL = "/index.php/ajaxserver/vehiclebyid/" +
vehID + "/" ;
var tag = "#choice" + loop2 ;
alert("loadURL: " + loadURL + "\nTag: " + tag) ;
$(tag).bind("click",function() {
loadXMLDoc(loadURL) ;
$("#dialogpane").html("") ;
}) ;
}
Any JavaScript expertise out there?
Eric
--
# Eric Lucas
#
# "Oh, I have slipped the surly bond of earth
# And danced the skies on laughter-silvered wings...
# -- John Gillespie Magee Jr
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|