...

View Full Version : Last step



dreamsonthefly
01-09-2004, 01:07 AM
I (with the help of members on this site) have developed a quiz via javascriptkt. It worked for w while and now the only thing missing is the submission of the results to me. The results show up on the form page, I put in the correct data to submit, but when I hit the submit button, it does not submit and gives me an error msg.

My question is: Does the error msg. (line 168) directly correspond with the line in the script? And do you count every line, even those that have nothing on them. Below is the script. Any help would be appreciated as this is the last link to sending out a newsletter with a link to the quiz.

The link is http://www.dreamsonthefly.com/januaryquiz.html


<html>
<head>
<title>December Quiz</title>
<script type="text/javascript" src="quizconfig.js"></script>
<!--//
function setCookie() {
duit = new Date();
duit.setTime(duit.getTime() + 30*24*60*60*1000);
var expString = "; expires=" + duit.toGMTString();
document.cookie = document.title + expString;
}

function submitData() {
var dc = document.cookie;
if(dc.match(document.title)) {
notice = "Thank You for your interest in taking our "+document.title+".\n";
notice+= "BUT, YOU MAY ONLY SUBMIT THE TEST ONE TIME!\n";
notice+= "You will now be redirected to Our Home Page.\n";
alert(notice);
window.location.replace('/');
}
else {
var correct = document.result.CORRECT.value;
var sub = correct+ ' correct answers on your December Test!';
var name = document.thedata.NAME.value;
if (!name) {
alert('You must enter your name');
document.thedata.NAME.focus();
return false;
}
else {
document.senddata.NAME.value = name;
}
var contact = document.thedata.CONTACT.value;
if (!contact) {
alert('You must enter your e-mail address');
document.thedata.CONTACT.focus();
return false;
}
else {
document.senddata.CONTACT.value = contact;
}
var from = document.thedata.FROM.value;
if (!from) {
from = 'No Data Submitted';
document.senddata.FROM.value = from;
}
else {
document.senddata.FROM.value = from;
}
var comment = document.thedata.COMMENT.value;
if (!comment) {
comment = 'No Comments Made.';
document.senddata.COMMENT.value = comment;
}
else {
document.senddata.COMMENT.value = comment;
}
document.senddata.PERCENTAGE.value = document.result.q.value;
document.senddata.CORRECT_ANSWERS.value = document.result.p.value;
document.senddata.WRONG_ANSWERS.value = document.result.T2.value;
document.senddata.action="http://pub7.bravenet.com/emailfwd/senddata.php"
document.senddata.submit();
}
}
// -->
</script>
</head>

<body bgcolor="#FFFFFF" onunload="setCookie()">
<p align="center"><strong><font face="Arial">
<big>Instant Quiz Results</big></font></strong></p>

<div align="center">
<center>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form name="result">
<input type="hidden" name="CORRECT" value="">
<table border="0" width="100%" cellpadding="0" height="116">
<tr>
<td height="25" bgcolor="#DBE0F5"><strong><font face="Arial"># of questions you got right:</font></strong></td>
<td height="25"><p><input type="text" name="p" size="24"></td>
</tr>
<tr>
<td height="17" bgcolor="#DBE0F5"><strong><font face="Arial">The questions you got wrong:</font></strong></td>
<td height="17"><p><textarea name="T2" rows="3" cols="24" wrap="virtual"></textarea></td>
</tr>
<tr>
<td height="25" bgcolor="#DBE0F5"><strong><font face="Arial">Grade in percentage:</font></strong></td>
<td height="25"><input type="text" name="q" size="8"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</div>

<div align="center">
<center>
<p>
<script type="text/javascript">
var wrong=0
for (e=0;e<=2;e++)
document.result[e].value=""

var results=document.cookie.split(";")
for (n=0;n<=results.length-1;n++){
if (results[n].charAt(1)=='q')
parse=n
}

var incorrect=results[parse].split("=")
incorrect=incorrect[1].split("/")
if (incorrect[incorrect.length-1]=='b')
incorrect=""
document.result[1].value=totalquestions-incorrect.length+" out of "+totalquestions
document.result[3].value=(totalquestions-incorrect.length)/totalquestions*100+"%"
for (temp=0;temp<incorrect.length;temp++)
document.result[2].value+=incorrect[temp]+", "
correct = totalquestions-incorrect.length;
document.result.CORRECT.value = correct;
</script>
<form name="thnx">
<input type="button" value="Submit your answers by entering your information below" name="B1" onClick="location.replace('/');">
</form>


<!-- Start Bravenet.com Service Code -->
<div align=center>

<div style="border:1px solid #999999; width:255px; margin-bottom:5px;background-color:#F2F4FA;">
<form name="senddata" method="post" enctype="multipart/form-data" style="margin:0px;">
<input type="hidden" name="NAME" value="" />
<input type="hidden" name="CONTACT" value="" />
<input type="hidden" name="FROM" value="" />
<input type="hidden" name="COMMENT" value="" />
<input type="hidden" name="PERCENTAGE" value="" />
<input type="hidden" name="CORRECT_ANSWERS" value="" />
<input type="hidden" name="WRONG_ANSWERS" value="" />
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<input type="hidden" name="usernum" value="587815930" />
<input type="hidden" name="cpv" value="2" />
</form>

<div style="background-color:#DBE0F5; padding:3px; font:12px arial; color:black;">
<b>Your Answers will submit automatically when you complete this form</b>
</div>

<form name="thedata">
<div style="padding:10px; font: normal 12px Arial; text-align:left;">
What is your name?<br />
<input type="text" name="NAME" size="34" style="width:230px;" /><br />
E-mail address?<br />
<input type="text" name="CONTACT" size="34" style="width:230px;" /><br />
Where are you from?<br />
<input type="text" name="FROM" size="34" style="width:230px;" /><br />
Any Comments?<br />
<input type="text" name="COMMENT" size="34" style="width:230px;" /><br />
</form>
</div>

<div align="center">
<form name="datasubmit">
<input type="button" name="send" value=" Submit" onClick="submitData();">
<input type="button" name="reset" value=" Clear " onClick="document.thedata.reset();">
</form>
</div>

<div align="center" style="margin:10px;">
<a style="font: bold 10px tahoma,arial; text-decoration: none;"
href="http://www.bravenet.com" target="_new">
powered by <img src="http://images.bravenet.com/bravenet/images/poweredby.gif"
border="0" align="absmiddle" alt="Powered by Bravenet" /> bravenet.com</a>
</div>

</div>
</div>
<!-- End Bravenet.com Service Code --></div>

<p id="footnote" align="center"><font face="arial" size="-1">Quiz script provided by<br>
<a href="http://www.javascriptkit.com">JavaScriptKit.com</a></font></p>
</body>
</html>

Thank you.


__________________
Dreams on the Fly
http://www.dreamsonthefly.com

Willy Duitt
01-09-2004, 04:15 AM
Sorry I forgot about you. :o
I'll go check my mail now.
.....Willy

dreamsonthefly
01-09-2004, 04:17 AM
Ah Willy:

A girl goes and gets married and is now forgotten!

dreamsonthefly
01-09-2004, 05:04 AM
How'd you do that? It's working. I have looked at that script trying to diagnose the problem, and viola you found it. Where the heck was it?

Rhonda

Willy Duitt
01-09-2004, 05:04 AM
Originally posted by dreamsonthefly
Ah Willy:

A girl goes and gets married and is now forgotten!

Well there are more fish in the sea you know! :D
Congrats on your nuptials! ;)

I just looked at your page and found the opening script tags missing.

html>
<head>
<title>January Quiz</title>
<script type="text/javascript" src="quizconfig.js"></script>
<script type="text/javascript" >
<!--//
function setCookie() {
duit = new Date();
duit.setTime(duit.getTime() + 30*24*60*60*1000);
var expString = "; expires=" + duit.toGMTString();
document.cookie = document.title + expString;
}

function submitData() {

I just made the changes on my copies and submitted the test.
Let me know if you recieve the results. If so, I'll send you the
revised codes as an attachment.

.....Willy

Willy Duitt
01-09-2004, 05:10 AM
Originally posted by dreamsonthefly
How'd you do that? It's working. I have looked at that script trying to diagnose the problem, and viola you found it. Where the heck was it?

Rhonda

I guess this means you got the results. :p
Can you add:
<script type="text/javascript">

Or would you like me to send an attachement?

Also; On my copy, I have changed this line:

else {
var correct = document.result.CORRECT.value;
var sub = correct+ ' correct answers on your '+document.title+'!';

So that only the title of the page needs to change month to
month and there should be no further script changes.

.....Willy

dreamsonthefly
01-09-2004, 05:15 AM
I can put in the <script type="text/javascript">

where else {
var correct = document.result.CORRECT.value;
var sub = correct+ ' correct answers on your '+document.title+'!';

you want me to put it in like this

else {
var correct = document.result.CORRECT.value;
var sub = correct+ ' correct answers on your '+januaryquiz.html+'!';

Willy Duitt
01-09-2004, 05:33 AM
No;

Change this line:

var sub = correct+ ' correct answers on your December Test!';

With this:

var sub = correct+ ' correct answers on your '+document.title+'!';

This way you would only need to change your document title from
month to month and not have to make any further changes to
the resuls.htm page codes

EG:

<html>
<head>
<title>December Quiz</title>
<script type="text/javascript" src="quizconfig.js"></script>

.....Willy

dreamsonthefly
01-09-2004, 05:43 AM
Willy, I think it best that I delete all of the past ones. So I am going to delete them and if you can send me the revised one, the one we just tested, I should only have one of these in my files. It's so difficult not being able to rename them.

Thank you ever so much.

BTW...we have one spot available for steelhead fishing on the Hoh 3/7-3/10 or 3/25-3/27. You just fly, we'll do the rest.

Rhonda

Willy Duitt
01-09-2004, 05:59 AM
Sounds tempting, It would be dependent on the weather if I
could take off of work. Not that I'm afraid to fish in the rain,
but I am in the construction business. ;)

Yes; Please delete all copies you have so there will be
no worries of mixups. I'll go send the attachements now.

.....Willy

dreamsonthefly
01-09-2004, 06:06 AM
Yep I got your submission all works.

Thanks Willy, if you change your mind about the fishing you know where to find us.

Rhonda



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum