Hi, I've been trying to figuer this out for weeks now. I'm hoping someone here can help, or point me in the right directions. The code bellow is suppose to type out text1 2 and 3 at the same time, text 1 & 2 work fine but 3 seems to stop everything. But if I put "Hello" into the effects_text on the PHP side then it works fine or if there is nothing in text3 it works fine aswell. I'm positive it's not coming from the PHP side cause I'm able to print out the variables text1, text2, and text3 in javascript. Here is the code:
Any ideas?
Thanks in advance,
Josh
Code:
<?php
session_start();
require_once('../../includes/database.php');
DBConnection();
$qr = mysql_query("select round, cha_string, opp_string, effect_string from `combat` where ID = '". $_SESSION['ID'] ."'");
$row = mysql_fetch_array($qr);
$round = $row['round'];
if ($round == "0") {
echo "Starting...";
} else {
echo "<CENTER><B> ROUND $round </B></CENTER><BR>";
$cha_text = $row['cha_string'];
$opp_text = $row['opp_string'];
$effects_text = $row['effect_string'];
}
?>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var text= <?php print "'".$cha_text."'"; ?>;
var delay=100;
var currentChar=1;
var destination="[not defined]";
var text2= <?php print "'".$effects_text."'"; ?>;
var delay2=100;
var currentChar2=1;
var destination2="[not defined]";
var text3= <?php print "'".$effects_text."'"; ?>;
var delay3=100;
var currentChar3=1;
var destination3="[not defined]";
function type()
{
if (document.getElementById)
{
var dest=document.getElementById(destination);
if (dest)
{
dest.innerHTML=text.substr(0, currentChar);
currentChar++
if (currentChar>text.length)
{
currentChar=1;
setTimeout("type()", 10000000000);
}
else
{
setTimeout("type()", delay);
}
}
}
}
function type2()
{
if (document.getElementById)
{
var dest=document.getElementById(destination2);
if (dest)
{
dest.innerHTML=text2.substr(0, currentChar2);
currentChar2++
if (currentChar2>text2.length)
{
currentChar2=1;
setTimeout("type2()", 100000000000);
//setTimeout("startTyping3(text3, '100', \"textDestination3\")", 5000);
}
else
{
setTimeout("type2()", delay2);
}
}
}
}
function type3()
{
if (document.getElementById)
{
var dest=document.getElementById(destination3);
if (dest)
{
dest.innerHTML=text3.substr(0, currentChar3);
currentChar3++
if (currentChar3>text3.length)
{
currentChar3=1;
setTimeout("type3()", 100000000000);
parent.controls.location.href = "controls.php";
parent.challanger.location.reload();
parent.opponet.location.reload();
// Refresh the pages here...
}
else
{
setTimeout("type3()", delay3);
}
}
}
}
function startTyping(textParam, delayParam, destinationParam)
{
text=textParam;
delay=delayParam;
currentChar=1;
destination=destinationParam;
type();
}
function startTyping2(textParam2, delayParam2, destinationParam2)
{
text2=textParam2;
delay2=delayParam2;
currentChar2=1;
destination2=destinationParam2;
type2();
}
function startTyping3(textParam3, delayParam3, destinationParam3)
{
text3=textParam3;
delay3=delayParam3;
currentChar3=1;
destination3=destinationParam3;
type3();
}
function myScroll() { // scroll to bottom of wwindow
window.scrollBy(0,100)
setTimeout('myScroll()',1000); // scrolls every 1000 miliseconds
}
//-->
</SCRIPT>
<title></title>
</head>
<body>
<DIV ID="textDestination">...</DIV>
<BR><BR>
<DIV ID="textDestination2">...</DIV>
<BR>
<DIV ID="textDestination3">...</DIV>
</body>
<SCRIPT LANGUAGE="JavaScript">
<!--
startTyping(text, 100, "textDestination");
startTyping2(text2, 100, "textDestination2");
startTyping3(text3, 100, "textDestination3");
myScroll();
//-->
</SCRIPT>
</html>
Any ideas?
Thanks in advance,
Josh