/    Sign up×
Community /Pin to ProfileBookmark

Help with hidden fields

I am trying to do a frame creating a math quiz. I am wanting to use hidden fields for the answers to the quize. When clicking the submit button I want to execute the onsubmit even handler and determine if the questions have been answered. If not then I want an alert to answer all the questions. If all answers are completed then I want to score the quiz using the answers in the hidden fields. I am having trouble with the answers if they are completed. Please help!!! Here is all the files I have so far.

Here is mapquizone.html

<html>
<head>
<title>Student Quiz</title>
<script language=”JavaScript”>
function confirmSubmit()
{
var sendForm = confirm
(“Did you fill out the form completely?”);
if (sendForm == true)
return true;
return false;
}
function confirmReset()
{
var resetForm = confirm
(“Are you sure you want to reset the quiz”);
if (resetForm == true)
return true;
return false;
}

parent.topframeone.document.hiddenElements.question1.value = document.mathquizone.question1.value;
parent.topframeone.document.hiddenElements.question2.value = document.mathquizone.question2.value;
parent.topframeone.document.hiddenElements.question3.value = document.mathquizone.question3.value;
if (parent.topframeone.document.hiddenElements.question1.value == “”
|| parent.topframeone.document.hiddenElements.question2.value == “”
|| parent.topframeone.document.hiddenElements.question3.value == “”)
alert(“You must answer all the questions.”);
else

</script>
</head>
<body>
<form action=”” method=”post” name=”” onSubmit=”return confirmSubmit();”;onReset=”return confirmReset();”>
<h3>Select the correct answer for the following questions.</h3>
<form>
<p>1. 2+4=</p>
<p><input type=radio name=question1 value=”10″
onClick=”scoreQuestion1(this.value)”>10
<p><input type=radio name=question1 value=”6″
onClick=”scoreQuestion1(this.value)”>6
<p><input type=radio name=question1 value=”7″
onClick=”scoreQuestion1(this.value)”>7</p>
<p>2. 4*4=</p>
<p><input type=radio name=question2 value=”16″
onClick=”scoreQuestion2(this.value)”>16
<p><input type=radio name=question2 value=”12″
onClick=”scoreQuestion2(this.value)”>12
<p><input type=radio name=question2 value=”19″
onClick=”scoreQuestion2(this.value)”>19
<p>3. 16/4=</p>
<p><input type=radio name=question3 value=”4″
onClick=”scoreQuestion3 (this.value)”>4<br>
<p><input type=radio name=question3 value=”3″
onClick=”scoreQuestion3 (this.value)”>3<br>
<p><input type=radio name=question3 value=”17″
onClick=”scoreQuestion3 (this.value)”>17<br>

<p><input type=”reset”>
<input type=”submit”>
</form>
</body>
</html>

Here is topframeone.html

<html>
<body>
<h1><b><i>Math Quiz</i></b></h1>
<form name=”hiddenElements”>
<input type=”hidden” name=”question1″>
<input type=”hidden” name=”question2″>
<input type=”hidden” name=”question3″>
</form>
</body>
</html>

Here is mathquiz.html

<html>
<head>
<title>Math Quiz</title>
</head>
<frameset rows=”60,*”>
<frame src=”topframeone.html” name=”topframeone” scrolling=no>
<frame src=”mathquizone.html” name=”bottomframe”>
onReset=”reset confirmReset();”
</frameset>
</html>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @hpettet 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.15,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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