/    Sign up×
Community /Pin to ProfileBookmark

script just aint workin

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 ” nr”.
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>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@BoooozeauthorAug 24.2003 — 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?.....
Copy linkTweet thisAlerts:
@ExuroAug 24.2003 — Okay, I fixed your code... Kind of... It still doesn't [i]do[/i] anything though. You were missing a ) and a + in there, hence the "object expected" error. Anyway, here it is:

[FONT=courier new]

<script LANGUAGE="JavaScript" type="text/javascript">

var reTurn = "r" // i.e, " r" or " nr".

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>

[/FONT]



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

Success!

Help @Booooze spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...