Onclick problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shock

    Onclick problem

    Hello everyone,

    I am having a problem with the program below. I have isolated the problem
    to the onclick event that is located throughout arrQuestions. The onclick
    event refers to a function and passes it two parameters. For the life of me
    I cannot figure out what the error is, but one occurs everytime I click a
    &%*$&# radio button. Also, the function only alerts the user immediately
    as to what question/answer they clicked. I am pretty much a rookie at
    Javascript so I would appreciate any help that anyone might have time to
    give.

    <?xml version = "1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns = "http://www.w3.org/1999/xhtml">

    <head>
    <title>Nascar Online Quiz</title>

    <script type = "text/javascript">

    <!--

    var totalCorrect = 0;

    var arrAnswers = new Array(10);

    var arrCorrectAnswe rs = new Array("c", "d", "a", "c", "c", "d", "a", "c",
    "b", "a");

    var arrQuestions = new Array("<b>Who is the seven time Winston Cup Champion
    who lost his life in the 2001 Daytona 500?</b><p>" +
    "\n" +
    "<input type='radio' name='question1 ' value='a'
    onclick='funRec ordAnswer(1, this.value)'>Je ff Gordon<br />" +
    "<input type='radio' name='question1 ' value='b'
    onclick='funRec ordAnswer(1, this.value)'>Ri chard Petty<br />" +
    "<input type='radio' name='question1 ' value='c'
    onclick='funRec ordAnswer(1, this.value)'>Da le Earnhardt<br />" +
    "<input type='radio' name='question1 ' value='d'
    onclick='funRec ordAnswer(1, this.value)'>Fi reball Roberts<br />" +
    "</p>",

    "<b>Which Winston Cup driver is a two-time Busch Grand National
    Series Champion and holds four straight wins at Talladega AL?</b><p>" +
    "\n" +
    "<input type='radio' name='question2 ' value='a'
    onclick='funRec ordAnswer(2, this.value)'>Bo bby Labonte<br />" +
    "<input type='radio' name='question2 ' value='b'
    onclick='funRec ordAnswer(2, this.value)'>Ku rt Busch<br />" +
    "<input type='radio' name='question2 ' value='c'
    onclick='funRec ordAnswer(2, this.value)'>To ny Stewart<br />" +
    "<input type='radio' name='question2 ' value='d'
    onclick='funRec ordAnswer(2, this.value)'>Da le Earnhardt, Jr<br />" +
    "</p>",

    "<b>Which Winston Cup driver come from Las Vegas Nevada where he
    used to stack groceries to pay for racing on weekends?</b><p>" +
    "\n" +
    "<input type='radio' name='question3 ' value='a'
    onclick='funRec ordAnswer(3, this.value)'>Ku rt Busch<br />" +
    "<input type='radio' name='question3 ' value='b'
    onclick='funRec ordAnswer(3, this.value)'>Ke n Schrader<br />" +
    "<input type='radio' name='question3 ' value='c'
    onclick='funRec ordAnswer(3, this.value)'>Ma tt Kenseth<br />" +
    "<input type='radio' name='question3 ' value='d'
    onclick='funRec ordAnswer(3, this.value)'>Mi ke Skinner<br />" +
    "</p>",

    "<b>Which Winston cup driver is a four-time champion known as boy
    wonder?</b><p>" +
    "\n" +
    "<input type='radio' name='question4 ' value='a'
    onclick='funRec ordAnswer(4, this.value)'>Ry an Newman<br />" +
    "<input type='radio' name='question4 ' value='b'
    onclick='funRec ordAnswer(4, this.value)'>Ji mmie Johnson<br />" +
    "<input type='radio' name='question4 ' value='c'
    onclick='funRec ordAnswer(4, this.value)'>Je ff Gordon<br />" +
    "<input type='radio' name='question4 ' value='d'
    onclick='funRec ordAnswer(4, this.value)'>Ja mie McMurray<br />" +
    "</p>",

    "<b>Which Winston cup driver hails from Missouri and owns a
    dirt-track outside of St. Louis?</b><p>" +
    "\n" +
    "<input type='radio' name='question5 ' value='a'
    onclick='funRec ordAnswer(5, this.value)'>Ca sey Mears<br />" +
    "<input type='radio' name='question5 ' value='b'
    onclick='funRec ordAnswer(5, this.value)'>Jo e Nemechek<br />" +
    "<input type='radio' name='question5 ' value='c'
    onclick='funRec ordAnswer(5, this.value)'>Ke n Schrader<br />" +
    "<input type='radio' name='question5 ' value='d'
    onclick='funRec ordAnswer(5, this.value)'>Ji mmy Spencer<br />" +
    "</p>",

    "<b>Which driver has won more races in their career?</b><p>" +
    "\n" +
    "<input type='radio' name='question6 ' value='a'
    onclick='funRec ordAnswer(6, this.value)'>Ru sty Wallace<br />" +
    "<input type='radio' name='question6 ' value='b'
    onclick='funRec ordAnswer(6, this.value)'>Ma rk Martin<br />" +
    "<input type='radio' name='question6 ' value='c'
    onclick='funRec ordAnswer(6, this.value)'>Da le Jarrett<br />" +
    "<input type='radio' name='question6 ' value='d'
    onclick='funRec ordAnswer(6, this.value)'>Je ff Gordon<br />" +
    "</p>",

    "<b>Which of these drivers is from Missouri?</b><p>" +
    "\n" +
    "<input type='radio' name='question7 ' value='a'
    onclick='funRec ordAnswer(7, this.value)'>Ru sty Wallace<br />" +
    "<input type='radio' name='question7 ' value='b'
    onclick='funRec ordAnswer(7, this.value)'>Ma rk Martin<br />" +
    "<input type='radio' name='question7 ' value='c'
    onclick='funRec ordAnswer(7, this.value)'>Da le Jarrett<br />" +
    "<input type='radio' name='question7 ' value='d'
    onclick='funRec ordAnswer(7, this.value)'>Je ff Gordon<br />" +
    "</p>",

    "<b>Which driver was beaten by Dale Earnhardt for the 1990 Winston
    Cup Championship?</b><p>" +
    "\n" +
    "<input type='radio' name='question8 ' value='a'
    onclick='funRec ordAnswer(8, this.value)'>Ru sty Wallace<br />" +
    "<input type='radio' name='question8 ' value='b'
    onclick='funRec ordAnswer(8, this.value)'>Ne d Jarrett<br />" +
    "<input type='radio' name='question8 ' value='c'
    onclick='funRec ordAnswer(8, this.value)'>Ma rk Martin<br />" +
    "<input type='radio' name='question8 ' value='d'
    onclick='funRec ordAnswer(8, this.value)'>Da le Earnhardt, Jr<br />" +
    "</p>",

    "<b>Who currently drives the M&Ms sponsored car in Winston
    Cup?</b><p>" +
    "\n" +
    "<input type='radio' name='question9 ' value='a'
    onclick='funRec ordAnswer(9, this.value)'>Ke n Schrader<br />" +
    "<input type='radio' name='question9 ' value='b'
    onclick='funRec ordAnswer(9, this.value)'>El liott Sadler<br />" +
    "<input type='radio' name='question9 ' value='c'
    onclick='funRec ordAnswer(9, this.value)'>St erling Marlin<br />" +
    "<input type='radio' name='question9 ' value='d'
    onclick='funRec ordAnswer(9, this.value)'>Ri cky Craven<br />" +
    "</p>",

    "<b>Which of these drivers was a high school quarterback in
    Nashville TN?</b><p>" +
    "\n" +
    "<input type='radio' name='question1 0' value='a'
    onclick='funRec ordAnswer(10, this.value)'>St erling Marlin<br />" +
    "<input type='radio' name='question1 0' value='b'
    onclick='funRec ordAnswer(10, this.value)'>Jo hnny Benson<br />" +
    "<input type='radio' name='question1 0'
    value='c' onclick='funRec ordAnswer(10, this.value)'>Ke nny Wallace<br />" +
    "<input type='radio' name='question1 0'
    value='d' onclick='funRec ordAnswer(10, this.value)'>St eve Park<br />" +
    "</p>"

    );

    function funPrintQuestio ns() {
    var arrTest = new Array();
    var j = 0;
    var Test = false;

    while ( j < 5) {
    r_num = Math.floor(Math .random() * 10);

    for ( var i = 0; i < arrTest.length; i++ ) {
    if ( r_num == arrTest[i]) {
    Test=true;
    }
    }

    if ( Test == true ) {
    Test = false;
    continue;
    }
    else
    {
    arrTest[j] = r_num;
    document.write( arrQuestions[r_num]);
    j++;
    }

    } // end while
    } // end function funPrintQuestio ns

    function funInitialize() {
    for ( var i = 0; i < arrAnswers.leng th; i++ )
    arrAnswers[i] = "";

    } // end funInitialize

    function funRecordAnswer ( question, answer ) {

    window.alert(qu estion);
    window.alert(an swer);
    return;

    } // end funRecordAnswer

    function funPrintButtons () {

    document.write( "<input type = 'button' value='Grade Quiz'
    onclick='funGra deQuiz()'>");
    document.write( "<input type = 'button' value='Refresh Quiz'
    onclick='locati on.reload()'>") ;

    } // end funPrintButtons

    function funGradeQuiz() {

    for ( var i = 0; i < 10; i++ ) {
    if ( arrAnswers[i] == arrCorrectAnswe rs[i] )
    totalCorrect++;
    }

    window.alert("Y ou got " + totalCorrect + " correct!");
    return;
    } // end funGradeQuiz

    // -->

    </script>

    </head>

    <body onLoad = "funInitialize( ); funPrintQuestio ns(); funPrintButtons ();">



    </body>

    </html>

    Thanks in advance,

    Shock


  • Thomas 'PointedEars' Lahn

    #2
    Re: Onclick problem

    Shock wrote:
    [color=blue]
    > I am having a problem with the program below. I have isolated the problem
    > to the onclick event that is located throughout arrQuestions. The onclick
    > event refers to a function and passes it two parameters. For the life of me
    > I cannot figure out what the error is,[/color]

    For Internet Explorer, you should go to Internet Options, Enhanced, Show
    script errors.[1] In Mozilla/5.0 (incl. Netscape 6.2x+) you go to Tools,
    Web Development, JavaScript Console. And in Opera (7), enable File,
    Preferences, Multimedia, JavaScript, Open JavaScript Console on errors.[1]

    [1] I don't now if this is the correct translation because I have only
    German versions of the software here.
    [color=blue]
    > but one occurs everytime I click a &%*$&# radio button.[/color]

    "There is an error" is an insufficient error *description*.
    You could have at least told us with which browser(s) you have tested.
    [color=blue]
    > [...]
    > <?xml version = "1.0"?>
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    >
    > <html xmlns = "http://www.w3.org/1999/xhtml">
    >
    > <head>
    > <title>Nascar Online Quiz</title>
    >
    > <script type = "text/javascript">
    >
    > <!--[/color]

    XHTML is an XML application, and a standards-compliant XML parser will cut
    out the contents of the `script' element because it is required to remove
    all comments from the markup before building the parse tree.

    Do not use common SGML commenting for hiding scripts/style sheets in XHTML,
    but declare the contents of such elements als CDATA which should not be
    parsed. Then you *may* add the comment, for the agreement that a script
    engine should ignore the leading `<!--':

    <script type="text/javascript">
    // <![CDATA[
    // <!--
    ...
    //-->
    // ]]>
    </script>

    It is likely that this will also solve your script problems.
    What is undefined, cannot be called (in event handlers.)
    [color=blue]
    > document.write( arrQuestions[r_num]);[/color]

    There is no document.write( ...) method for the XHTML DOM because that
    could result in not well-formatted markup. If you use XHTML, you must
    stick to the W3C-DOM and build the document node by node, using the
    document.create ...(...) and HTMLElement.app endChild(...) methods.

    BTW: It is a Bad Thing[tm] to create documents that look empty without
    client-side JavaScript. Use a server-side solution instead.


    PointedEars

    Comment

    • Shock

      #3
      Re: Onclick problem

      For the sake of simplicity I tore out the XML/XHTML references and left the
      javascript code strictly within HTML tags. Sorry I didn't post the message,
      3 am and I wasn't thinking clearly. The error message is still the same
      "line 6, object expected. I still think that the onclick event isn't
      finding the function I have specified, but I don't know why.

      Shock

      BTW IE6

      Here is the latest version of the code

      <html>

      <head>
      <title>Nascar Online Quiz</title>

      <script type = "text/javascript">

      <!--

      var totalCorrect = 0;

      var arrAnswers = new Array(10);

      var arrCorrectAnswe rs = new Array("c", "d", "a", "c", "c", "d", "a", "c",
      "b", "a");

      var arrQuestions = new Array("<b>Who is the seven time Winston Cup Champion
      who lost his life in the 2001 Daytona 500?</b><p>" +
      "\n" +
      "<input type='radio' name='question1 ' value='a'
      onclick='funRec ordAnswer(1, this.value)'>Je ff Gordon<br />" +
      "<input type='radio' name='question1 ' value='b'
      onclick='funRec ordAnswer(1, this.value)'>Ri chard Petty<br />" +
      "<input type='radio' name='question1 ' value='c'
      onclick='funRec ordAnswer(1, this.value)'>Da le Earnhardt<br />" +
      "<input type='radio' name='question1 ' value='d'
      onclick='funRec ordAnswer(1, this.value)'>Fi reball Roberts<br />" +
      "</p>",

      "<b>Which Winston Cup driver is a two-time Busch Grand National
      Series Champion and holds four straight wins at Talladega AL?</b><p>" +
      "\n" +
      "<input type='radio' name='question2 ' value='a'
      onclick='funRec ordAnswer(2, this.value)'>Bo bby Labonte<br />" +
      "<input type='radio' name='question2 ' value='b'
      onclick='funRec ordAnswer(2, this.value)'>Ku rt Busch<br />" +
      "<input type='radio' name='question2 ' value='c'
      onclick='funRec ordAnswer(2, this.value)'>To ny Stewart<br />" +
      "<input type='radio' name='question2 ' value='d'
      onclick='funRec ordAnswer(2, this.value)'>Da le Earnhardt, Jr<br />" +
      "</p>",

      "<b>Which Winston Cup driver come from Las Vegas Nevada where he
      used to stack groceries to pay for racing on weekends?</b><p>" +
      "\n" +
      "<input type='radio' name='question3 ' value='a'
      onclick='funRec ordAnswer(3, this.value)'>Ku rt Busch<br />" +
      "<input type='radio' name='question3 ' value='b'
      onclick='funRec ordAnswer(3, this.value)'>Ke n Schrader<br />" +
      "<input type='radio' name='question3 ' value='c'
      onclick='funRec ordAnswer(3, this.value)'>Ma tt Kenseth<br />" +
      "<input type='radio' name='question3 ' value='d'
      onclick='funRec ordAnswer(3, this.value)'>Mi ke Skinner<br />" +
      "</p>",

      "<b>Which Winston cup driver is a four-time champion known as boy
      wonder?</b><p>" +
      "\n" +
      "<input type='radio' name='question4 ' value='a'
      onclick='funRec ordAnswer(4, this.value)'>Ry an Newman<br />" +
      "<input type='radio' name='question4 ' value='b'
      onclick='funRec ordAnswer(4, this.value)'>Ji mmie Johnson<br />" +
      "<input type='radio' name='question4 ' value='c'
      onclick='funRec ordAnswer(4, this.value)'>Je ff Gordon<br />" +
      "<input type='radio' name='question4 ' value='d'
      onclick='funRec ordAnswer(4, this.value)'>Ja mie McMurray<br />" +
      "</p>",

      "<b>Which Winston cup driver hails from Missouri and owns a
      dirt-track outside of St. Louis?</b><p>" +
      "\n" +
      "<input type='radio' name='question5 ' value='a'
      onclick='funRec ordAnswer(5, this.value)'>Ca sey Mears<br />" +
      "<input type='radio' name='question5 ' value='b'
      onclick='funRec ordAnswer(5, this.value)'>Jo e Nemechek<br />" +
      "<input type='radio' name='question5 ' value='c'
      onclick='funRec ordAnswer(5, this.value)'>Ke n Schrader<br />" +
      "<input type='radio' name='question5 ' value='d'
      onclick='funRec ordAnswer(5, this.value)'>Ji mmy Spencer<br />" +
      "</p>",

      "<b>Which driver has won more races in their career?</b><p>" +
      "\n" +
      "<input type='radio' name='question6 ' value='a'
      onclick='funRec ordAnswer(6, this.value)'>Ru sty Wallace<br />" +
      "<input type='radio' name='question6 ' value='b'
      onclick='funRec ordAnswer(6, this.value)'>Ma rk Martin<br />" +
      "<input type='radio' name='question6 ' value='c'
      onclick='funRec ordAnswer(6, this.value)'>Da le Jarrett<br />" +
      "<input type='radio' name='question6 ' value='d'
      onclick='funRec ordAnswer(6, this.value)'>Je ff Gordon<br />" +
      "</p>",

      "<b>Which of these drivers is from Missouri?</b><p>" +
      "\n" +
      "<input type='radio' name='question7 ' value='a'
      onclick='funRec ordAnswer(7, this.value)'>Ru sty Wallace<br />" +
      "<input type='radio' name='question7 ' value='b'
      onclick='funRec ordAnswer(7, this.value)'>Ma rk Martin<br />" +
      "<input type='radio' name='question7 ' value='c'
      onclick='funRec ordAnswer(7, this.value)'>Da le Jarrett<br />" +
      "<input type='radio' name='question7 ' value='d'
      onclick='funRec ordAnswer(7, this.value)'>Je ff Gordon<br />" +
      "</p>",

      "<b>Which driver was beaten by Dale Earnhardt for the 1990 Winston
      Cup Championship?</b><p>" +
      "\n" +
      "<input type='radio' name='question8 ' value='a'
      onclick='funRec ordAnswer(8, this.value)'>Ru sty Wallace<br />" +
      "<input type='radio' name='question8 ' value='b'
      onclick='funRec ordAnswer(8, this.value)'>Ne d Jarrett<br />" +
      "<input type='radio' name='question8 ' value='c'
      onclick='funRec ordAnswer(8, this.value)'>Ma rk Martin<br />" +
      "<input type='radio' name='question8 ' value='d'
      onclick='funRec ordAnswer(8, this.value)'>Da le Earnhardt, Jr<br />" +
      "</p>",

      "<b>Who currently drives the M&Ms sponsored car in Winston
      Cup?</b><p>" +
      "\n" +
      "<input type='radio' name='question9 ' value='a'
      onclick='funRec ordAnswer(9, this.value)'>Ke n Schrader<br />" +
      "<input type='radio' name='question9 ' value='b'
      onclick='funRec ordAnswer(9, this.value)'>El liott Sadler<br />" +
      "<input type='radio' name='question9 ' value='c'
      onclick='funRec ordAnswer(9, this.value)'>St erling Marlin<br />" +
      "<input type='radio' name='question9 ' value='d'
      onclick='funRec ordAnswer(9, this.value)'>Ri cky Craven<br />" +
      "</p>",

      "<b>Which of these drivers was a high school quarterback in
      Nashville TN?</b><p>" +
      "\n" +
      "<input type='radio' name='question1 0' value='a'
      onclick='funRec ordAnswer(10, this.value)'>St erling Marlin<br />" +
      "<input type='radio' name='question1 0' value='b'
      onclick='funRec ordAnswer(10, this.value)'>Jo hnny Benson<br />" +
      "<input type='radio' name='question1 0'
      value='c' onclick='funRec ordAnswer(10, this.value)'>Ke nny Wallace<br />" +
      "<input type='radio' name='question1 0'
      value='d' onclick='funRec ordAnswer(10, this.value)'>St eve Park<br />" +
      "</p>"

      );

      function funPrintQuestio ns() {
      var arrTest = new Array();
      var j = 0;
      var Test = false;

      while ( j < 5) {
      r_num = Math.floor(Math .random() * 10);

      for ( var i = 0; i < arrTest.length; i++ ) {
      if ( r_num == arrTest[i]) {
      Test=true;
      }
      }

      if ( Test == true ) {
      Test = false;
      continue;
      }
      else
      {
      arrTest[j] = r_num;
      document.write( arrQuestions[r_num]);
      j++;
      }

      } // end while
      } // end function funPrintQuestio ns

      function funInitialize() {
      for ( var i = 0; i < arrAnswers.leng th; i++ )
      arrAnswers[i] = "";

      } // end funInitialize

      function funRecordAnswer ( question, answer ) {

      window.alert(qu estion);
      window.alert(an swer);
      return;

      } // end funRecordAnswer

      function funPrintButtons () {

      document.write( "<input type = 'button' value='Grade Quiz'
      onclick='funGra deQuiz()'>");
      document.write( "<input type = 'button' value='Refresh Quiz'
      onclick='locati on.reload()'>") ;

      } // end funPrintButtons

      function funGradeQuiz() {

      for ( var i = 0; i < 10; i++ ) {
      if ( arrAnswers[i] == arrCorrectAnswe rs[i] )
      totalCorrect++;
      }

      window.alert("Y ou got " + totalCorrect + " correct!");
      return;
      } // end funGradeQuiz

      // -->

      </script>

      </head>

      <body onLoad = "funInitialize( ); funPrintQuestio ns(); funPrintButtons ();">



      </body>

      </html>


      Comment

      • Richard Cornford

        #4
        Re: Onclick problem

        "Shock" <shock56@charte r.net> wrote in message
        news:votqdda7n8 fh65@corp.super news.com...
        <snip>[color=blue]
        > function funPrintButtons () {
        >
        > document.write( "<input type = 'button' value='Grade Quiz'
        > onclick='funGra deQuiz()'>");
        > document.write( "<input type = 'button' value='Refresh Quiz'
        > onclick='locati on.reload()'>") ;
        >
        > } // end funPrintButtons[/color]
        snip>[color=blue]
        ><body
        >onLoad = "funInitialize( ); funPrintQuestio ns(); funPrintButtons ();">[/color]
        <snip>

        You are calling document.write after the original document has been
        closed (in the onload event). That will result in the current document
        being cleared and replaced, and when it is cleared all of the JavaScript
        functions go with it.

        Richard.


        Comment

        • Shock

          #5
          Re: Onclick problem

          Sorry, I am not sure I understand. I thought document.write simply wrote
          the line into the document. When was the document closed?

          Shock


          "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
          news:bmmu4a$gkm $1$8302bc10@new s.demon.co.uk.. .[color=blue]
          > "Shock" <shock56@charte r.net> wrote in message
          > news:votqdda7n8 fh65@corp.super news.com...
          > <snip>[color=green]
          > > function funPrintButtons () {
          > >
          > > document.write( "<input type = 'button' value='Grade Quiz'
          > > onclick='funGra deQuiz()'>");
          > > document.write( "<input type = 'button' value='Refresh Quiz'
          > > onclick='locati on.reload()'>") ;
          > >
          > > } // end funPrintButtons[/color]
          > snip>[color=green]
          > ><body
          > >onLoad = "funInitialize( ); funPrintQuestio ns(); funPrintButtons ();">[/color]
          > <snip>
          >
          > You are calling document.write after the original document has been
          > closed (in the onload event). That will result in the current document
          > being cleared and replaced, and when it is cleared all of the JavaScript
          > functions go with it.
          >
          > Richard.
          >
          >[/color]


          Comment

          • Lasse Reichstein Nielsen

            #6
            Re: Onclick problem

            "Shock" <shock56@charte r.net> writes:
            [color=blue]
            > Sorry, I am not sure I understand. I thought document.write simply wrote
            > the line into the document. When was the document closed?[/color]

            The document was closed when it finished loading, i.e., *just* before
            the document's onload event happens.

            While loading the page, the page is processed from top to bottom. A
            script is executed when this process reaches it, and a document.write
            inserts content between the script that calls it and the remaining,
            unprocessed, code.

            When processing reaches the end of the document, it is finished. This
            closes the document and then calls the onload handler. That means that
            document.write' s in the onload handler will reopen, and thereby clear,
            the document.

            /L
            --
            Lasse Reichstein Nielsen - lrn@hotpop.com
            Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
            'Faith without judgement merely degrades the spirit divine.'

            Comment

            • Shock

              #7
              Re: Onclick problem

              Ok, I understand what you mean, but now I am confused on how to get the
              functions to work without actually calling them.

              Thanks,

              Shock
              "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
              news:7k34q2mp.f sf@hotpop.com.. .[color=blue]
              > "Shock" <shock56@charte r.net> writes:
              >[color=green]
              > > Sorry, I am not sure I understand. I thought document.write simply[/color][/color]
              wrote[color=blue][color=green]
              > > the line into the document. When was the document closed?[/color]
              >
              > The document was closed when it finished loading, i.e., *just* before
              > the document's onload event happens.
              >
              > While loading the page, the page is processed from top to bottom. A
              > script is executed when this process reaches it, and a document.write
              > inserts content between the script that calls it and the remaining,
              > unprocessed, code.
              >
              > When processing reaches the end of the document, it is finished. This
              > closes the document and then calls the onload handler. That means that
              > document.write' s in the onload handler will reopen, and thereby clear,
              > the document.
              >
              > /L
              > --
              > Lasse Reichstein Nielsen - lrn@hotpop.com
              > Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
              > 'Faith without judgement merely degrades the spirit divine.'[/color]


              Comment

              • Shock

                #8
                Re: Onclick problem

                Ok, I got it.. I just put a direct call in for the first function after I
                defined my global variables and arrays. It works and I understand it better
                now...I had just never put a direct call in the script like
                that...duh..heh e..
                .. Thanks everybody for the help!

                Shock

                "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
                news:7k34q2mp.f sf@hotpop.com.. .[color=blue]
                > "Shock" <shock56@charte r.net> writes:
                >[color=green]
                > > Sorry, I am not sure I understand. I thought document.write simply[/color][/color]
                wrote[color=blue][color=green]
                > > the line into the document. When was the document closed?[/color]
                >
                > The document was closed when it finished loading, i.e., *just* before
                > the document's onload event happens.
                >
                > While loading the page, the page is processed from top to bottom. A
                > script is executed when this process reaches it, and a document.write
                > inserts content between the script that calls it and the remaining,
                > unprocessed, code.
                >
                > When processing reaches the end of the document, it is finished. This
                > closes the document and then calls the onload handler. That means that
                > document.write' s in the onload handler will reopen, and thereby clear,
                > the document.
                >
                > /L
                > --
                > Lasse Reichstein Nielsen - lrn@hotpop.com
                > Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
                > 'Faith without judgement merely degrades the spirit divine.'[/color]


                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: Onclick problem

                  Shock wrote:
                  [color=blue]
                  > For the sake of simplicity I tore out the XML/XHTML references and left the
                  > javascript code strictly within HTML tags. Sorry I didn't post the message,
                  > 3 am and I wasn't thinking clearly. The error message is still the same
                  > "line 6, object expected. I still think that the onclick event isn't
                  > finding the function I have specified, but I don't know why.
                  > [...]
                  > var arrQuestions = new Array("<b>Who is the seven time Winston Cup Champion
                  > who lost his life in the 2001 Daytona 500?</b><p>" +
                  > "\n" +
                  > "<input type='radio' name='question1 ' value='a'
                  > onclick='funRec ordAnswer(1, this.value)'>Je ff Gordon<br />" +[/color]

                  The document.write( ...) issue aside, you need to mask SGML End Tag Open
                  (ETAGO) delimiters (`</') in HTML-embedded JavaScript with `<\/', otherwise
                  a strict SGML Parser will assume the end of the `script' element. And you
                  do not want to use XML syntax (<tag />) in HTML, because it is the short tag
                  syntax there.

                  Please do not post your entire source code (240 lines!) here, but only the
                  necessary fragments. If you think the whole source code is required, post
                  an URL to the document, previously uploading it if necessary. Bandwidth is
                  precious.


                  PointedEars

                  Comment

                  Working...