I really need help people. I have checked my script from all ways it can be checked and my problem is with the document.write() code. I start off by writing my whole 'body' with the document.write() . at this stage all is fine!. but now, I want to rewrite the whole document again completly from top to bottom- so I call a function that calls another function that contains the 2nd document with all the document.write() in it. well...... There is an error and the second document is functioning like it should. actually the second document is much like the first one accept a change in 1 of the images location.
here's the code ("bu()" is the first document and "bu2()" is the 2nd):
<html>
<head>
<title>
project
</title>
<script language="javascript">
var x=1;var y=10; var z=1;
bu();
function good()
{
bu2();
alert("1"
;
getRandom();
}
function bad()
{
alert("2"
}
function getRandom()
{
x=(Math.round(Math.random()*(6-1)))+1
if (x==y)
{ if (x==6)
{x=x-1}
x=x+1
}
y=x;
b4.src=x+"/8.jpg";
b3.src=x+"/2.jpg";
b2.src=x+"/3.jpg";
b1.src=x+"/4.jpg";
}
function bu()
{
document.write("<table hspace='0' vspace='0' cellSpacing=5 cellPadding=0 border=0 vAlign=top align=center>"
document.write("<tr>"
document.write("<td align='center'> <img name='b1' src=1/2.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("<td align='center'> <img name='b2' src=1/3.jpg WIDTH='100' HEIGHT='100' onClick='bad()' >"
document.write("</td>"
document.write("<td align='center'> <img name='b3' src=1/4.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("<td align='center'> <img name='b4' src=1/8.jpg WIDTH='100' HEIGHT='100' onClick='good()'>"
document.write("</td>"
document.write("</tr>"
document.write("</table>"
}
function bu2()
{
document.close()
document.open()
document.write("<table hspace='0' vspace='0' cellSpacing=5 cellPadding=0 border=0 vAlign=top align=center>"
document.write("<tr>"
document.write("<td align='center'> <img name='b1' src=1/2.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("<td align='center'> <img name='b2' src=1/3.jpg WIDTH='100' HEIGHT='100' onClick='bad()' >"
document.write("</td>"
document.write("<td align='center'> <img name='b4' src=1/8.jpg WIDTH='100' HEIGHT='100' onClick='good()' >"
document.write("</td>"
document.write("<td align='center'> <img name='b3' src=1/4.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("</tr>"
document.write("</table>"
}
</script>
</head>
<body>
</body>
</html>
THX A LOT!
here's the code ("bu()" is the first document and "bu2()" is the 2nd):
<html>
<head>
<title>
project
</title>
<script language="javascript">
var x=1;var y=10; var z=1;
bu();
function good()
{
bu2();
alert("1"
getRandom();
}
function bad()
{
alert("2"
}
function getRandom()
{
x=(Math.round(Math.random()*(6-1)))+1
if (x==y)
{ if (x==6)
{x=x-1}
x=x+1
}
y=x;
b4.src=x+"/8.jpg";
b3.src=x+"/2.jpg";
b2.src=x+"/3.jpg";
b1.src=x+"/4.jpg";
}
function bu()
{
document.write("<table hspace='0' vspace='0' cellSpacing=5 cellPadding=0 border=0 vAlign=top align=center>"
document.write("<tr>"
document.write("<td align='center'> <img name='b1' src=1/2.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("<td align='center'> <img name='b2' src=1/3.jpg WIDTH='100' HEIGHT='100' onClick='bad()' >"
document.write("</td>"
document.write("<td align='center'> <img name='b3' src=1/4.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("<td align='center'> <img name='b4' src=1/8.jpg WIDTH='100' HEIGHT='100' onClick='good()'>"
document.write("</td>"
document.write("</tr>"
document.write("</table>"
}
function bu2()
{
document.close()
document.open()
document.write("<table hspace='0' vspace='0' cellSpacing=5 cellPadding=0 border=0 vAlign=top align=center>"
document.write("<tr>"
document.write("<td align='center'> <img name='b1' src=1/2.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("<td align='center'> <img name='b2' src=1/3.jpg WIDTH='100' HEIGHT='100' onClick='bad()' >"
document.write("</td>"
document.write("<td align='center'> <img name='b4' src=1/8.jpg WIDTH='100' HEIGHT='100' onClick='good()' >"
document.write("</td>"
document.write("<td align='center'> <img name='b3' src=1/4.jpg WIDTH='100' HEIGHT='100' onClick='bad()' > "
document.write("</td>"
document.write("</tr>"
document.write("</table>"
}
</script>
</head>
<body>
</body>
</html>
THX A LOT!