?
Solved

Passing a value across frames

Posted on 2003-03-02
8
Medium Priority
?
135 Views
Last Modified: 2008-03-17
Ok, gator4life has been a HUGE help to me, much thanks for that.  Now that I have my radio buttons validating, I need to pass the values of the fields.

The script I have calculates the number of "yes" answers on each page and puts them into 6 separate fields(a - f), according to how they are answered.  I need to keep track of how many "yes" answers there are across 9 pages of questions, and add them up at the end.

Here's the twist!

The questions are labeled from a to f.  Question 1 is a, 2 is b, 3 is c, 4 is d, 5 is e, 6 is f, 7 is a, 8 is b, etc.  I have my code calculating how many a "yes", how many b "yes", etc.

I need the a yesses in one field, b yesses in another field, etc.

How can I pass these values on, and add the new amount of "yesses" from each page into a frame?

I hope it's not too confusing!
0
Comment
Question by:ashleypower
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 

Author Comment

by:ashleypower
ID: 8055027
Sorry, I forgot the source code!  Here it is:

<HTML>

<HEAD>
<TITLE>TEST</TITLE>

<SCRIPT language = JavaScript>

<!--

if (window.focus) self.focus();

function addyes() {

   var totals=[0,0,0,0,0,0];
   var numquestions=18;
 
   for(i=0;i<numquestions;i++)
       if(eval("document.quiz.Q" + (i+1) + "[0].checked") )
           totals[i%6]++;

   for(i=0; i<6; i++)
       eval("document.quiz." + String.fromCharCode(97+i) + ".value=totals[" + i + "];");

}


function check() {

   var iNumQuestions = 18;

   for (var i = 1; i <= iNumQuestions; i++) {

        var bOneChecked = false;
        var aRadios = document.getElementsByName('Q' + i);

        for (var j = 0; j < aRadios.length; j++) {

             if (aRadios[j].checked) bOneChecked = true;
        }

        if (!bOneChecked) return false;
   }

   return true;
}



//-->

</SCRIPT>

</HEAD>

<BODY>

<FORM NAME = "quiz">

<TABLE CELLSPACING = "10">

<TR>
<TD>1(A). One</TD>
<TD><INPUT TYPE = "radio"  NAME="Q1" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q1" VALUE = "no">No</TD>
</TR>

<TR>
<TD>2(B). Two</TD>
<TD><INPUT TYPE = "radio"  NAME="Q2" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q2" VALUE = "no">No</TD>
</TR>

<TR>
<TD>3(C). Three</TD>
<TD><INPUT TYPE = "radio"  NAME="Q3" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q3" VALUE = "no">No</TD>
</TR>

<TR>
<TD>4(D). Four</TD>
<TD><INPUT TYPE = "radio"  NAME="Q4" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q4" VALUE = "no">No</TD>
</TR>

<TR>
<TD>5(E). Five</TD>
<TD><INPUT TYPE = "radio"  NAME="Q5" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q5" VALUE = "no">No</TD>
</TR>

<TR>
<TD>6(F). Six</TD>
<TD><INPUT TYPE = "radio"  NAME="Q6" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q6" VALUE = "no">No</TD>
</TR>

<TR>
<TD>7(A). Seven</TD>
<TD><INPUT TYPE = "radio"  NAME="Q7" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q7" VALUE = "no">No</TD>
</TR>

<TR>
<TD>8(B). Eight</TD>
<TD><INPUT TYPE = "radio"  NAME="Q8" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q8" VALUE = "no">No</TD>
</TR>

<TR>
<TD>9(C). Nine</TD>
<TD><INPUT TYPE = "radio"  NAME="Q9" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q9" VALUE = "no">No</TD>
</TR>

<TR>
<TD>10(D). Ten</TD>
<TD><INPUT TYPE = "radio"  NAME="Q10" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q10" VALUE = "no">No</TD>
</TR>

<TR>
<TD>11(E). Eleven</TD>
<TD><INPUT TYPE = "radio"  NAME="Q11" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q11" VALUE = "no">No</TD>
</TR>

<TR>
<TD>12(F). Twelve</TD>
<TD><INPUT TYPE = "radio"  NAME="Q12" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q12" VALUE = "no">No</TD>
</TR>

<TR>
<TD>13(A). Thirteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q13" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q13" VALUE = "no">No</TD>
</TR>

<TR>
<TD>14(B). Fourteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q14" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q14" VALUE = "no">No</TD>
</TR>

<TR>
<TD>15(C). Fifteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q15" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q15" VALUE = "no">No</TD>
</TR>

<TR>
<TD>16(D). Sixteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q16" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q16" VALUE = "no">No</TD>
</TR>

<TR>
<TD>17(E). Seventeen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q17" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q17" VALUE = "no">No</TD>
</TR>

<TR>
<TD>18(F). Eighteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q18" VALUE = "yes">Yes
<INPUT TYPE = "radio" NAME="Q18" VALUE = "no">No</TD>
</TR>


</TABLE>

<INPUT TYPE = "button" VALUE = "Calculate" onClick="JavaScript: if (!check()) alert('Not all answered!'); else addyes();">
<INPUT TYPE = reset VALUE = "Clear"></B>

<P>

Sum of YES A = <INPUT SIZE = "3" NAME = "a" VALUE=0>
<P>
Sum of YES B = <INPUT SIZE = "3" NAME = "b" VALUE=0>
<P>
Sum of YES C = <INPUT SIZE = "3" NAME = "c" VALUE=0>
<P>
Sum of YES D = <INPUT SIZE = "3" NAME = "d" VALUE=0>
<P>
Sum of YES E = <INPUT SIZE = "3" NAME = "e" VALUE=0>
<P>
Sum of YES F = <INPUT SIZE = "3" NAME = "f" VALUE=0>
</FORM>

</BODY>

</HTML>
0
 
LVL 4

Expert Comment

by:jonnal
ID: 8059384
hi
this page is calling itself
change the location in ...ask1..ask2 ??
function setsrc(){
for(i=0;i<totals.length;i++)
lasttotals[i]=parseInt(lasttotals[i])+parseInt(totals[i]);
location = 'ask.htm?'+lasttotals.join('x');
}
in each page to point to the next

this script could be made to update the sum boxes by
adding "cal();" to the end off
getsrc()
addyes()
cleartotals()

here is the code
=========================================================
<HTML>

<HEAD>
<TITLE>TEST</TITLE>

<SCRIPT language = JavaScript>

<!--

if (window.focus) self.focus();

var totals=[0,0,0,0,0,0];
var lasttotals =[0,0,0,0,0,0];

function cleartotals(){
for(i=0;i<totals.length;i++)
totals[i]=0;
}

function cal() {
   for(i=0; i<6; i++)
      eval("document.quiz." + String.fromCharCode(97+i) + ".value=totals[" + i + "]+parseInt(lasttotals["+i+"]);");

}
function addyes(inx) {
var pint = inx.replace("Q","");
var t = (pint-1)%6;

      if(eval("document.forms[\"quiz\"].elements[\"Q"+pint+"\"][0].checked") )
          totals[t]++;
                  else
                  if(totals[t]>=1)totals[t]--;
}getsrc()addyes()cleartotals()


function check() {

  var iNumQuestions = 18;

  for (var i = 1; i <= iNumQuestions; i++) {

       var bOneChecked = false;
       var aRadios = document.getElementsByName('Q' + i);

       for (var j = 0; j < aRadios.length; j++) {

            if (aRadios[j].checked) bOneChecked = true;
       }

       if (!bOneChecked) return false;
  }

  return true;
}

function getsrc(){

if(location.search != ""){
var stri = location.search.substring(1,location.search.length)
lasttotals=stri.split('x');
}



}
function setsrc(){
for(i=0;i<totals.length;i++)
lasttotals[i]=parseInt(lasttotals[i])+parseInt(totals[i]);
location = 'ask.htm?'+lasttotals.join('x');
}

//-->

</SCRIPT>

</HEAD>

<BODY onload="getsrc()">

<FORM NAME = "quiz">

<TABLE CELLSPACING = "10">

<TR>
<TD>1(A). One</TD>
<TD><INPUT TYPE = "radio"  NAME="Q1" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q1" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>2(B). Two</TD>
<TD><INPUT TYPE = "radio"  NAME="Q2" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q2" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>3(C). Three</TD>
<TD><INPUT TYPE = "radio"  NAME="Q3" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q3" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>4(D). Four</TD>
<TD><INPUT TYPE = "radio"  NAME="Q4" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q4" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>5(E). Five</TD>
<TD><INPUT TYPE = "radio"  NAME="Q5" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q5" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>6(F). Six</TD>
<TD><INPUT TYPE = "radio"  NAME="Q6" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q6" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>7(A). Seven</TD>
<TD><INPUT TYPE = "radio"  NAME="Q7" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q7" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>8(B). Eight</TD>
<TD><INPUT TYPE = "radio"  NAME="Q8" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q8" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>9(C). Nine</TD>
<TD><INPUT TYPE = "radio"  NAME="Q9" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q9" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>10(D). Ten</TD>
<TD><INPUT TYPE = "radio"  NAME="Q10" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q10" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>11(E). Eleven</TD>
<TD><INPUT TYPE = "radio"  NAME="Q11" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q11" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>12(F). Twelve</TD>
<TD><INPUT TYPE = "radio"  NAME="Q12" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q12" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>13(A). Thirteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q13" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q13" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>14(B). Fourteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q14" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q14" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>15(C). Fifteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q15" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q15" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>16(D). Sixteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q16" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q16" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>17(E). Seventeen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q17" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q17" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>18(F). Eighteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q18" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q18" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>


</TABLE>

<INPUT TYPE = "button" VALUE = "Calculate" onClick="JavaScript: if (!check()) alert('Not all answered!'); else cal();">
<INPUT TYPE = reset VALUE = "Clear" onclick="cleartotals()"></B>

<P>

Sum of YES A = <INPUT SIZE = "3" NAME = "a" VALUE=0>
<P>
Sum of YES B = <INPUT SIZE = "3" NAME = "b" VALUE=0>
<P>
Sum of YES C = <INPUT SIZE = "3" NAME = "c" VALUE=0>
<P>
Sum of YES D = <INPUT SIZE = "3" NAME = "d" VALUE=0>
<P>
Sum of YES E = <INPUT SIZE = "3" NAME = "e" VALUE=0>
<P>
Sum of YES F = <INPUT SIZE = "3" NAME = "f" VALUE=0>

</FORM>
<br><a href="#" onclick="JavaScript: if (!check()) alert('Not all answered!'); else setsrc();return false">next page</a>
</BODY>

</HTML>
0
 

Author Comment

by:ashleypower
ID: 8063784
Error on line 78 aparently!  It doesn't work.  Thanks for your help tho.  Is there any way that I can do what i'm asking without changing the existing code I have?  Maybe add more to my existing "add" function?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:jonnal
ID: 8064210
hi
the error is in line 33
I cut and pasted the function names to point out which functions
you need to add cal() to make the values update in real time
and should have removed them

remove these, but leave the '}' in place on line 33
getsrc()addyes()cleartotals()

having a look at the rest of question now
0
 

Author Comment

by:ashleypower
ID: 8064462
This is what I have now:

<HTML>

<HEAD>
<TITLE>TEST</TITLE>

<SCRIPT language = JavaScript>

<!--

if (window.focus) self.focus();

var totals=[0,0,0,0,0,0];
var lasttotals =[0,0,0,0,0,0];

function cleartotals(){
for(i=0;i<totals.length;i++)
totals[i]=0;
}

function cal() {
  for(i=0; i<6; i++)
     eval("document.quiz." + String.fromCharCode(97+i) + ".value=totals[" + i + "]+parseInt(lasttotals["+i+"]);");

}
function addyes(inx) {
var pint = inx.replace("Q","");
var t = (pint-1)%6;

     if(eval("document.forms[\"quiz\"].elements[\"Q"+pint+"\"][0].checked") )
         totals[t]++;
               else
               if(totals[t]>=1)totals[t]--;
}


function check() {

 var iNumQuestions = 18;

 for (var i = 1; i <= iNumQuestions; i++) {

      var bOneChecked = false;
      var aRadios = document.getElementsByName('Q' + i);

      for (var j = 0; j < aRadios.length; j++) {

           if (aRadios[j].checked) bOneChecked = true;
      }

      if (!bOneChecked) return false;
 }

 return true;
}

function getsrc(){

if(location.search != ""){
var stri = location.search.substring(1,location.search.length)
lasttotals=stri.split('x');
}



}
function setsrc(){
for(i=0;i<totals.length;i++)
lasttotals[i]=parseInt(lasttotals[i])+parseInt(totals[i]);
location = 'test2.htm?'+lasttotals.join('x');
}

//-->

</SCRIPT>

</HEAD>

<BODY onload="getsrc()">

<FORM NAME = "quiz">

<TABLE CELLSPACING = "10">

<TR>
<TD>1(A). One</TD>
<TD><INPUT TYPE = "radio"  NAME="Q1" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q1" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>2(B). Two</TD>
<TD><INPUT TYPE = "radio"  NAME="Q2" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q2" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>3(C). Three</TD>
<TD><INPUT TYPE = "radio"  NAME="Q3" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q3" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>4(D). Four</TD>
<TD><INPUT TYPE = "radio"  NAME="Q4" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q4" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>5(E). Five</TD>
<TD><INPUT TYPE = "radio"  NAME="Q5" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q5" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>6(F). Six</TD>
<TD><INPUT TYPE = "radio"  NAME="Q6" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q6" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>7(A). Seven</TD>
<TD><INPUT TYPE = "radio"  NAME="Q7" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q7" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>8(B). Eight</TD>
<TD><INPUT TYPE = "radio"  NAME="Q8" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q8" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>9(C). Nine</TD>
<TD><INPUT TYPE = "radio"  NAME="Q9" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q9" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>10(D). Ten</TD>
<TD><INPUT TYPE = "radio"  NAME="Q10" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q10" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>11(E). Eleven</TD>
<TD><INPUT TYPE = "radio"  NAME="Q11" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q11" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>12(F). Twelve</TD>
<TD><INPUT TYPE = "radio"  NAME="Q12" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q12" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>13(A). Thirteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q13" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q13" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>14(B). Fourteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q14" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q14" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>15(C). Fifteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q15" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q15" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>16(D). Sixteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q16" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q16" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>17(E). Seventeen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q17" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q17" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>

<TR>
<TD>18(F). Eighteen</TD>
<TD><INPUT TYPE = "radio"  NAME="Q18" VALUE = "yes" onclick="addyes(this.name)">Yes
<INPUT TYPE = "radio" NAME="Q18" VALUE = "no" onclick="addyes(this.name)">No</TD>
</TR>


</TABLE>

<INPUT TYPE = "button" VALUE = "Calculate" onClick="JavaScript: if (!check()) alert('Not all answered!'); else cal();">
<INPUT TYPE = reset VALUE = "Clear" onclick="cleartotals()"></B>

<P>

Sum of YES A = <INPUT SIZE = "3" NAME = "a" VALUE=0>
<P>
Sum of YES B = <INPUT SIZE = "3" NAME = "b" VALUE=0>
<P>
Sum of YES C = <INPUT SIZE = "3" NAME = "c" VALUE=0>
<P>
Sum of YES D = <INPUT SIZE = "3" NAME = "d" VALUE=0>
<P>
Sum of YES E = <INPUT SIZE = "3" NAME = "e" VALUE=0>
<P>
Sum of YES F = <INPUT SIZE = "3" NAME = "f" VALUE=0>

</FORM>
<br><a href="test2.htm" onclick="JavaScript: if (!check()) alert('Not all answered!'); else setsrc();return false">next page</a>
</BODY>

</HTML>

Now, the answers are shown in the address bar like this:

file:///C:/WINDOWS/Desktop/test2.htm?3x3x3x3x3x3

but the values do not go into the fields.  Am I doing something wrong.  Please keep in mind that I really dont know what i'm doing!  Haha.  Thanks for your patience guys.
0
 

Author Comment

by:ashleypower
ID: 8064557
Ok, with a bit of messing around, I got it working, but it passes the value to a frame.  

Now the only problem that I have is that when I move on to the next page, I want the values ADDED on to the current values in the frame fields.  Now, it REPLACES them.

Here's what i've got:
===========================================
FRAMESET:

<HTML>

<HEAD>

<SCRIPT LANGUAGE = "JavaScript">

function passa(str) {

top.frames['values'].document.values.a.value = str;

}

function passb(str) {

top.frames['values'].document.values.b.value = str;

}

function passc(str) {

top.frames['values'].document.values.c.value = str;

}

function passd(str) {

top.frames['values'].document.values.d.value = str;

}

function passe(str) {

top.frames['values'].document.values.e.value = str;

}

function passf(str) {

top.frames['values'].document.values.f.value = str;

}

</SCRIPT>

</HEAD>

<FRAMESET COLS = "400,*">
<FRAME NAME = "quest" SRC = "test.htm">
<FRAME NAME = "values" SRC = "value.htm">
</FRAMESET>

</FORM>
</BODY>
</HTML>
=====================
QUESTIONS
=====================
<HTML>

<HEAD>
<TITLE>AAA Test Page 1</TITLE>

<STYLE>

TABLE {font-family: arial; font-size: 12px; font-weight: bold}

</STYLE>

<SCRIPT language = JavaScript>

<!--

if (window.focus) self.focus();

function addyes() {

   var totals=[0,0,0,0,0,0];
   var numquestions=24;
 
   for(i=0;i<numquestions;i++)
       if(eval("document.quiz.Q" + (i+1) + "[0].checked") )
           totals[i%6]++;

   for(i=0; i<6; i++)
       eval("document.quiz." + String.fromCharCode(97+i) + ".value=totals[" + i + "];");
}

function check() {

   var iNumQuestions = 18;

   for (var i = 1; i <= iNumQuestions; i++) {

        var bOneChecked = false;
        var aRadios = document.getElementsByName('Q' + i);

        for (var j = 0; j < aRadios.length; j++) {

             if (aRadios[j].checked) bOneChecked = true;
        }

        if (!bOneChecked) return false;
   }

   return true;
}

//-->

</SCRIPT>

</HEAD>

<BODY BGCOLOR = "#000099" TEXT = "#F8DE07">

<FORM NAME = "quiz">

<TABLE CELLPADDING = "4" CELLSPACING = "0" BORDER = "0">

<TR BGCOLOR = "#333399">
<TD>1(A). Fix a flat tire:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q1" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q1" VALUE = "no">No</TD>
</TR>

<TR>
<TD>2(B). Understand how carbon dating works:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q2" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q2" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>3(C). Play a musical instrument:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q3" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q3" VALUE = "no">No</TD>
</TR>

<TR>
<TD>4(D). Help people who need advice:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q4" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q4" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>5(E). Be a good salesperson:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q5" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q5" VALUE = "no">No</TD>
</TR>

<TR>
<TD>6(F). Operate a photocopier:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q6" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q6" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>7(A). Operate power tools such as a drill or sewing machine:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q7" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q7" VALUE = "no">No</TD>
</TR>

<TR>
<TD>8(B). Describe the function of the white blood cells:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q8" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q8" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>9(C). Participate in a church choir:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q9" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q9" VALUE = "no">No</TD>
</TR>

<TR>
<TD>10(D). Teach children how to tie shoelaces:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q10" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q10" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>11(E). Create a plan to achieve a goal:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q11" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q11" VALUE = "no">No</TD>
</TR>

<TR>
<TD>12(F). Filing paperwork:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q12" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q12" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>13(A). Read blueprints:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q13" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q13" VALUE = "no">No</TD>
</TR>

<TR>
<TD>14(B). Write a scientific or scholarly report:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q14" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q14" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>15(C). Express yourself through a painting or sculpture:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q15" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q15" VALUE = "no">No</TD>
</TR>

<TR>
<TD>16(D). Work well with others:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q16" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q16" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>17(E). Be a successful leader:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q17" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q17" VALUE = "no">No</TD>
</TR>

<TR>
<TD>18(F). Do alot of paperwork in a short time:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q18" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q18" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>19(A). Make simple electrical repairs:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q19" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q19" VALUE = "no">No</TD>
</TR>

<TR>
<TD>20(B). Understand the formula in a simple chemistry equation:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q20" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q20" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>21(C). Write your own songs:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q21" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q21" VALUE = "no">No</TD>
</TR>

<TR>
<TD>22(D). Understand people's actions:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q22" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q22" VALUE = "no">No</TD>
</TR>

<TR BGCOLOR = "#333399">
<TD>23(E). Be confortable speaking to crowds:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q23" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q23" VALUE = "no">No</TD>
</TR>

<TR>
<TD>24(F). Keep accurate records of payments or sales:</TD>
<TD><INPUT TYPE = "radio"  NAME="Q24" VALUE = "yes" checked>Yes
<INPUT TYPE = "radio" NAME="Q24" VALUE = "no">No</TD>
</TR>

</TABLE>

<INPUT TYPE = "button" VALUE = "Calculate" onClick="JavaScript: if (!check()) alert('You have left out one or more answers.  Please answer all questions.'); else addyes();
parent.passa(document.quiz.a.value);
parent.passb(document.quiz.b.value);
parent.passc(document.quiz.c.value);
parent.passd(document.quiz.d.value);
parent.passe(document.quiz.e.value);
parent.passf(document.quiz.f.value);">

<INPUT TYPE = "hidden" SIZE = "3" NAME = "a" VALUE = 0>
<INPUT TYPE = "hidden" SIZE = "3" NAME = "b" VALUE = 0>
<INPUT TYPE = "hidden" SIZE = "3" NAME = "c" VALUE = 0>
<INPUT TYPE = "hidden" SIZE = "3" NAME = "d" VALUE = 0>
<INPUT TYPE = "hidden" SIZE = "3" NAME = "e" VALUE = 0>
<INPUT TYPE = "hidden" SIZE = "3" NAME = "f" VALUE = 0>
</FORM>

<A HREF = "test2.htm"> NEXT </A>

</BODY>

</HTML>
=======================
FRAME THAT HOLDS VALUES
=======================
<HTML>
<BODY>

<FORM NAME = "values">

<INPUT TYPE = "text" SIZE = "3" NAME = "a" VALUE = 0>
<INPUT TYPE = "text" SIZE = "3" NAME = "b" VALUE = 0>
<INPUT TYPE = "text" SIZE = "3" NAME = "c" VALUE = 0>
<INPUT TYPE = "text" SIZE = "3" NAME = "d" VALUE = 0>
<INPUT TYPE = "text" SIZE = "3" NAME = "e" VALUE = 0>
<INPUT TYPE = "text" SIZE = "3" NAME = "f" VALUE = 0>
<INPUT TYPE = reset VALUE = "Clear">

</FORM>

</BODY>

</HTML>
==========================
PLEASE HELP!!!  I'm tearing my eyes out trying to do this!

0
 
LVL 4

Accepted Solution

by:
jonnal earned 50 total points
ID: 8066550
hi
I had to make some changes to were the script is in the frameset
 1 removed script from test.htm and placed in frameset head
so the values are always there.
 2 changed how the script is called, these 5 lines are the end of page test.html, remove everything from <INPUT TYPE = "button" VALUE = "Calculate" down
and offcourse remoe the script from head of test.htm
just leave the if (window.focus) self.focus();



<INPUT TYPE = "button" VALUE = "Calculate" onClick="JavaScript: if (!top.check()) alert('You have left out one or more answers.  Please answer all questions.'); else top.addyes();">
</FORM>
<A HREF = "#" onclick="top.nextpage('test2.htm');return true"> NEXT </A>
</BODY>
</HTML>

==========================================================
no changes made to value.htm
==========================================================

and this is index.htm

<HTML>

<HEAD>
<SCRIPT language = JavaScript>

<!--

 var totals=[0,0,0,0,0,0];
 var pagetotals =[0,0,0,0,0,0];

function addyes() {
cleartotals();
var numquestions=24;

  for(i=0;i<numquestions;i++)
      if(eval("top.frames[0].document.quiz.Q" + (i+1) + "[0].checked") )
          pagetotals[i%6]++;

     display();
}

function check() {

  var iNumQuestions = 18;

  for (var i = 1; i <= iNumQuestions; i++) {

       var bOneChecked = false;
       var aRadios = top.frames[0].document.getElementsByName('Q' + i);

       for (var j = 0; j < aRadios.length; j++) {

            if (aRadios[j].checked) bOneChecked = true;
       }

       if (!bOneChecked) return false;
  }

  return true;
}

var iput = ['a','b','c','d','e','f'];

function display(){
     for(i=0; i<6; i++)
     eval("top.frames['values'].document.values."+iput[i]+".value = "+(totals[i]+pagetotals[i])+";");
}
function cleartotals(){
     for(i=0;i<pagetotals.length;i++)
     pagetotals[i]=0;
}

function nextpage(page){
     for(i=0;i<pagetotals.length;i++)
     totals[i] += pagetotals[i];

top.frames[0].location.replace(page);
}
//-->

</SCRIPT>
</HEAD>
<FRAMESET COLS = "400,*">
<FRAME NAME = "quest" SRC = "test.htm">
<FRAME NAME = "values" SRC = "value.htm">
</FRAMESET>

</FORM>
</BODY>
</HTML>
========================================================

hope you see the need to put script in index.html
when you are doing your testxxx pages place the url in the call to nextpage('test2.htm')

jonnal
0
 

Author Comment

by:ashleypower
ID: 8075946
I figured it out on my own, but I appreciate the help!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question