Jump to content

finel edit


westman

Recommended Posts

i have this script and its working fully...

window.onload = otoload;function otoload() {var oto_update = <?php echo $id ?>;var url = "../oto_work.php";$.post(url,{ oto_update: oto_update }  ,  function(data) {chater = data;if (chater == "") {$("#whatisit").html('<a href="#" title="chat" onclick="return false" onmousedown="javascript:togglechat(\'chat\');"><img src="../image/chat.png" alt="chat" width="44" height="40" /></a>').show();} else {    $("#whatisit").html('<a href="#" title="chat" onclick="return false" onmousedown="javascript:togglechat(\'chat\');"><img src="../image/chat2.gif" alt="chat" width="44" height="40" /></a>').show();//$("#mem+chater").class.back3// code needed}});otoload_timer = setTimeout("otoload()",10000);}

now i need to add one line of code to finish it. The logic is i have many divs and the id of the divs is mem and a number (mem25 mem268 mem739 mem6 and so on...)the info in the varible "chater" hold numbers separaded by , (25,268,739,6 and so on...)for each number in the varible chater i am trying to make the div class change to back3 any help?

Link to comment
Share on other sites

If chater is an array you can loop through the numbers and assign back3 every time.

var cnt = chater.length;for (var i = 0, i < cnt; i++) {  $("#mem"+chater[i]).class.back3;}

Edited by Err
Link to comment
Share on other sites

with...

var num_list=chater.split(",");for (var i = 0; i < num_list.length; i++) {  $("#mem"+num_list[i]).removeClass("whatever_class").addClass("back3");}

i can see my image but it is not working...i left .removeClass("whatever_class") as it was coz the class will be "back1" or "back2" (set by php diynamicly)

Link to comment
Share on other sites

Well keep going I'm pretty sure your hit the correct solution pretty soon, it's like we can't do anything this end, as we have no idea what the html code with id, and classes looks like, or any js errors you are getting, so we can't help can we!

Link to comment
Share on other sites

my finel edit i now have...

window.onload = otoload;function otoload() {var oto_update = <?php echo $trueid ?>;var url = "../livechat/oto_work.php";$.post(url,{ oto_update: oto_update }  ,  function(data) {chater = data;if (chater == "") {$("#whatisit").html('<a href="#" title="T-chat" onclick="return false" onmousedown="javascript:toggletchat(\'tchat\');"><img src="../image/chat.png" alt="T-chat" width="44" height="40" style="border:0;" /></a>').show();//code needed} else {    $("#whatisit").html('<a href="#" title="T-chat" onclick="return false" onmousedown="javascript:toggletchat(\'tchat\');"><img src="../image/chat2.gif" alt="T-chat" width="44" height="40" style="border:0;" /></a>').show();var num_list=chater.slice(0,-1)num_list=num_list.split(",");for (var i = 0; i < num_list.length; i++) {  $("#mem"+num_list[i]).removeClass("back2").addClass("back3");}}});otoload_timer = setTimeout("otoload()",10000);}

and it is working fullyis there a way that i can set all divs to Class back2 without knowing the div id's?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...