Howdy,
I've recently written some Javascript code to see who's logged in on my website. In the script I create a list of names of the people who are online and store them in a string.
Does anyone know how I could get that string into <p></p> tags on my webpage.
I'm not sure about the return statement required to retreive the string, do I need to use print or echo in php (with the js inside the echo).. Help!
Code:<script type="text/javascript"> function onlineMembers(){ var usersOnline = new Array(7); var users = new Array(7); online = ""; usersOnline[0] = "jenny"; usersOnline[1] = "whitey99"; usersOnline[2] = "chett"; usersOnline[3] = "lean"; usersOnline[4] = "pipil"; usersOnline[5] = "sam"; usersOnline[6] = "james"; users [0] = "Jenny"; users [1] = "Whitey99"; users [2] = "Chett"; users [3] = "Lean"; users [4] = "Pipil"; users [5] = "Sam"; users [6] = "James"; if(document.cookie.length > 0){ // if there are any cookies for(i=0; i<7; i++){ search = usersOnline[i] + "="; offset = document.cookie.indexOf(search); if(offset != -1){ // if cookie exists online = online + "» " + users[i] + "\n\n"; // Second array for capitals } } } else{ online = "Geen leden online"; // When no members online } return online; } </script>


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks