chrisprse Posted May 16, 2009 Share Posted May 16, 2009 Hello I pass a variable to JavaScript from PHP. Currently this variable is 38. It will increase every time new records are stored in the database. This doesn't work: for(i = 1; i <= num_rows; i++) { $("a#link-" + i).mouseover(function() { $("#tip-" + i).show(); }) $("a#link-" + i).mouseout(function() { $("#tip-" + i).hide(); }) } Whereas this does: $("a#link-1").mouseover(function() { $("#tip-1").show(); $("a#link-1").mouseout(function() { $("#tip-1").hide(); $("a#link-2").mouseover(function() { $("#tip-2").show(); $("a#link-2").mouseout(function() { $("#tip-2").hide(); . . . $("a#link-38").mouseover(function() { $("#tip-38").show(); $("a#link-38").mouseout(function() { $("#tip-38").hide(); Obviously I don't want to edit this file everytime I have a new record in the database! Does anyone have any ideas? Regards Chris Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 16, 2009 Share Posted May 16, 2009 Verify num_rows is correct. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.