Click to See Complete Forum and Search --> : script just aint workin


Booooze
08-23-2003, 11:10 PM
can any1 tell me wats wrong with my code, im a noob, i think its a lil error, but is really a big problem that i made by using "sloppy" code..




<html>
<head>
<title>quiz</title>
<script LANGUAGE="JavaScript" type="text/javascript">


function writedata()
{
form2.quizsource.value = reTurn + "<html>" + reTurn + "<head>" + reTurn + "<title>"
+ form1.quizTitle.value + "</title>" + reTurn
+ "</head>" + reTurn + "<body bgcolor=#ffffff>" + reTurn + "<center><h1>"
+ form1.quizTitle.value + "</h1></center><hr>" + reTurn
form2.quizsource.value += "<form>" + reTurn + "<ol>" + reTurn
for (var i=1;1<10;) {
form2.quizsource.value += "\t" + questionsarray[i] + "<p>" + reTurn
if (answeraarray[i]!= "")
{
form2.quizsource.value += "\t<input type='button' value='A' onClick='alert(\"" + feedbkarray[i] + "\")'>" + reTurn
form2.quizsource.value += "\t" + answeraarray[i] + "<p>" + reTurn
form2.quizsource.value += "</ol>" reTurn + "</form></body>" + reTurn + "</html>"
}
}
}
</script>
</head>
<body>
<script LANGUAGE="JavaScript" type="text/javascript">
var reTurn = "\r" // i.e, " \r" or " \n\r".
answeraarray = new Array["document.form1.answer1.value"];
answerbarray = new Array["document.form1.answer3.value"];
answerdarray = new Array["document.form1.answer4.value"];
questionsarray = new Array["document.form1.question1.value"];
feedbkarray = new Array["document.form1.correctanswer.value"];
answeraarray = ["document.form1.answer1.value"];
answerbarray = ["document.form1.answer3.value"];
answerdarray = ["document.form1.answer4.value"];
questionsarray = ["document.form1.question1.value"];
feedbkarray = ["document.form1.correctanswer.value"];



</script>
<p>
<form name="form1">
Title:<input type="text" name="quizTitle" size="30">
Question:<input type="text" name="question1" size="30">
<br>A:<input type="text" name="answer1" size="30">
<br>B:<input type="text" name="answer2" size="30">
<br>C:<input type="text" name="answer3" size="30">
<br>D:<input type="text" name="answer4" size="30">
<br>Correct answer:<input type="text" name="correctanswer" size="30">
<hr>
</p>
</form>
<script LANGUAGE="JavaScript" type="text/javascript">
document.write("<input type='button' value='check' onClick='writedata();'>");


</script>

<form name="form2">
<TEXTAREA name="quizsource" rows="20" cols="80"></TEXTAREA>
</form>
</body>
</html>

Booooze
08-23-2003, 11:13 PM
and yes i just noticed that i have the little array problem there,lol, and yeah, the ie error checking says there's a problem at line 20 char 38(expected ';') and line 29 char 1(object expected), any suggestions, or should i just start again?.....

Exuro
08-23-2003, 11:44 PM
Okay, I fixed your code... Kind of... It still doesn't do anything though. You were missing a ) and a + in there, hence the "object expected" error. Anyway, here it is:


<script LANGUAGE="JavaScript" type="text/javascript">
var reTurn = "\r" // i.e, " \r" or " \n\r".

function writedata()
{
answeraarray = new Array(document.form1.answer1.value);
answerbarray = new Array(document.form1.answer3.value);
answerdarray = new Array(document.form1.answer4.value);
questionsarray = new Array(document.form1.question1.value);
feedbkarray = new Array(document.form1.correctanswer.value);
form2.quizsource.value = reTurn + "<html>" + reTurn + "<head>" + reTurn + "<title>" + form1.quizTitle.value + "</title>" + reTurn + "</head>" + reTurn + "<body bgcolor=#ffffff>" + reTurn + "<center><h1>" + form1.quizTitle.value + "</h1></center><hr>" + reTurn;
form2.quizsource.value += "<form>" + reTurn + "<ol>" + reTurn;
for (var i=0;i<10;i++) {
form2.quizsource.value += "\t" + questionsarray[i] + "<p>" + reTurn;
if (answeraarray[i] != "")
{
form2.quizsource.value += "\t<input type='button' value='A' onClick='alert(\"" + feedbkarray[i] + "\")'>" + reTurn;
form2.quizsource.value += "\t" + answeraarray[i] + "<p>" + reTurn;
form2.quizsource.value += "</ol>" + reTurn + "</form></body>" + reTurn + "<\/html>";
}
}
}
</script>


Oh yeah, you were also declaring your arrays incorrectly before. Anyway, good luck with this.