fert
-
Posts
1,114 -
Joined
-
Last visited
Never
Posts posted by fert
-
-
I'm working on a chat program that uses Javascript and Ajax. One of its features is tabbed chatting and the problem lies in the code to generate the tab bar.
function gen_buttons() { var arr; var x; var style; if(ajax.readyState==4) { document.getElementById("chattabs").innerHTML=""; arr=ajax.responseText; arr=arr.split(";"); for(x in arr) { chattabs[x]=arr[x]; if(x==current_tab) { style='style="background: black; color: white;"'; } else { style=""; } document.getElementById("chattabs").innerHTML+='<input type="button" '+style+' onClick="javascript:getchattext("'+chattabs[x]+'");" value="'+chattabs[x]+'"><input type="button" value="X" onClick="javascript:exitchat("'+chattabs[x]+'");">|'; alert(document.getElementById("chattabs").innerHTML); } } }
in the beginning arr holds a string that looks something like this
ChatRoom1;ChatRoom2
and then i split the string and
arr[0]="ChatRoom1"
arr[1]="ChatRoom2"
Then the code generates the tab bar. but instead of looking like this
<input type="button" style="background: black; color: white;" onClick="javascript:getchattext("ChatRoom1");" value="ChatRoom1"> <input type="button" value="X" onClick="javascript:exitchat("ChatRoom1");">| <input type="button" onClick="javascript:getchattext("ChatRoom2");" value="ChatRoom2"> <input type="button" value="X" onClick="javascript:exitchat("ChatRoom2");">|
it looks like this (note the odd =", extra spaces and capitalization)
<input style="background: black none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: white;" onclick="javascript:getchattext(" chatroom1="" );="" value="ChatRoom1" type="button"> <input value="X" onclick="javascript:exitchat(" chatroom1="" );="" type="button">| <input onclick="javascript:getchattext(" chatroom2="" );="" value="ChatRoom2" type="button"> <input value="X" onclick="javascript:exitchat(" chatroom2="" );="" type="button">|
getchatttext() switches to a new tab
exitchat() closes a tab
This must be the oddest Javascript bug i've ever encountered and I have no idea as to what is going wrong.
-
Story ended up being wrong anyways
The story you post said
a German schoolboy has recalculated the likelihood of a deadly planet-smasher asteroid hitting the Earth, and found the catastrophe is enormously more likely than NASA thought
-
I'm not too worried, even if it does hit it'll probably hit the ocean and because i'm not near the coast the mega tsunamis won't affect me.
-
And can I compile python into an executable that doesn't need to be installed
I believe there are python compliers, but usually python is an interpreted language
-
try using the computer terminal
-
The syntax of PHP is very similar to C++
-
I got 115 using Dvorak.
I can't be bothered to find out how to replace the keyboard on my laptop
just pop the keys out and swap them.
-
In general no. The only time i use OOP is to demonstrate that i know it.
-
$bad_words=array("bad word1","bad word2"); foreach($bad_words as $b) { $text=str_replace($b,"****",$text) }
-
I use gedit, the default text editor for ubuntu
-
$_GET['name_of_var']
-
to use myql_real_escape_string you have to be connected to the mysql server
-
just open the file and explode the commands and then loop through the array with the commands and run them.
-
-
-
set a cookie and then try to read the cookie you just set.
-
if(mysql_num_rows($results3)==0) { //etc }
-
#2: As far as my searches have turned up, there is no way to check if input is numeric... I need something like PHPs is_numeric().
the function atoi in stdlib.h returns 0 if the input is not a number.
#3: Within main() after answer() I want the program to "restart", so that the user can choose another option and go again, but I can't figure out how to do that.
create an infinite loop like this
for(; { //do something }
#4: I'd like to make it so a user can enter "exit" at any time to exit the program.
doing that would be kinda tricky, it's better to offer an option to exit and then use the exit() function in stdlib.h
-
or these would work
for(;;
cin.get();
-
are you using windows?
-
What about a Flash Game?
but what do you think the flash plugin is written in?
The only reason I would disagree with your roopurt18 is because C is not object oriented.
The only time i use OOP in coding is to show that i know how to.
-
do we have to recode it in php?
-
do I must go with zip too?
that doesn't make a zip archive, it makes a gzip archive you could go with other formats such as bzip.
-
why the hell are you doing this in php? go for C++
Having a problem with a chat program
in Javascript Help
Posted
Got it!
it works perfectly now. Thank you for your help!