Sorry: its my first script. what is wrong?

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

    Sorry: its my first script. what is wrong?

    Please can you find out what's wrong, fix the script and tell me what was
    wrong. Im just beginning


    <html>
    <head>
    <title>Random Mad Lib!</title>
    <script language="JavaS cript">
    <!-- Hide

    function displaymadlib(w 1, w2, w3, w4, w5, w6, w7, w8, w9, w0, w11, w22, w33,
    w44, w55) {

    document.writel n("The attack of the purple tissue!!!<br> Once there was
    a/an "
    + w1
    + " tissue attacking a "
    + w2
    + " in"
    + w3
    + "! The tissue was even"
    + w4
    + "the"
    + w5
    + "! 4"
    + w6
    + "died of heart attacks. The"
    + w7
    + "was"
    + w8
    + "Suddenly, "
    + 9
    + "man came to"
    + w0
    + "the"
    + w11
    + ". He went up to the tissue and kicked it in the
    + w22
    + ", and the tissue"
    + w33
    + "to the ground. Its snot covered the "
    + w44
    + ", and everything there"
    + w55
    + ".");return true
    }

    // stop hiding -->

    </SCRIPT>

    </head>

    <body onload="documen t.madlib.adj1.s elect()">

    <FORM NAME="madlib">
    <p>
    adjective:
    <input name="adj1"></p><br>
    <p>
    place:
    <input name="place1"></p><br>
    <p>
    another place:
    <input name="place2"></p><br>
    <p>
    verb:
    <input name="verb1"></p><br>
    <p>
    plural noun:
    <input name="pnoun1"></p><br>
    <p>
    another plural noun:
    <input name="pnoun2"></p><br>
    <p>
    place:
    <input name="place3"></p><br>
    <p>
    adjective:
    <input name="adj2"></p><br>
    <p>
    noun:
    <input name="noun1"></p><br>
    <p>
    verb:
    <input name="verb2"></p><br>
    <p>
    noun:
    <input name="noun2"></p><br>
    <p>
    body part:
    <input name="bpart"></p><br>
    <p>
    verb:
    <input name="verb3"></p><br>
    <p>
    place:
    <input name="place4"></p><br>
    <p>
    verb:
    <input name="verb4"></p><br>
    <p>
    <br>
    <p>

    <INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
    OnClick="displa ymadlib(documen t.madlib.adj1.v alue,
    document.madlib .place1.value, document.madlib .place2.value,
    document.madlib .verb1.value, document.madlib .pnoun1.value,
    document.madlib .pnoun2.value, document.madlib .place3.value,
    document.madlib .adj2.value, document.madlib .noun1.value,
    document.madlib .verb2.value, document.madlib .noun2.value,
    document.madlib .bpart.value, document.madlib .verb3.value,
    document.madlib .place4.value, document.madlib .verb4.value)">

    <INPUT TYPE="reset" VALUE="reset">

    </form>
    </body>

    </html>
  • Dominique

    #2
    Re: Sorry: its my first script. what is wrong?

    You just gotta check every line, coz its small mistakes like not closing a
    line with " etc...


    =============== =======
    <html>
    <head>
    <title>Random Mad Lib!</title>
    <script language="JavaS cript">
    <!-- Hide

    function displaymadlib() {
    w1 = document.madlib .adj1.value
    w2 = document.madlib .place1.value,
    w3 = document.madlib .place2.value
    w4 = document.madlib .verb1.value
    w5 = document.madlib .pnoun1.value
    w6 = document.madlib .pnoun2.value
    w7 = document.madlib .place3.value
    w8 = document.madlib .adj2.value
    w9 = document.madlib .noun1.value
    w10 = document.madlib .verb2.value
    w11 = document.madlib .noun2.value
    w12 = document.madlib .bpart.value
    w13 = document.madlib .verb3.value
    w14 = document.madlib .place4.value
    w15 = document.madlib .verb4.value

    document.writel n("The attack of the purple tissue!!!<br> Once there was
    a/an "
    + w1
    + " tissue attacking a "
    + w2
    + " in "
    + w3
    + "! The tissue was even "
    + w4
    + "the "
    + w5
    + "! 4 "
    + w6
    + "died of heart attacks. The "
    + w7
    + "was"
    + w8
    + "Suddenly, "
    + w9
    + "man came to"
    + w10
    + "the "
    + w11
    + ". He went up to the tissue and kicked it in the "
    + w12
    + ", and the tissue"
    + w13
    + "to the ground. Its snot covered the "
    + w14
    + ", and everything there "
    + w15
    + ".");return true
    }

    // stop hiding -->

    </SCRIPT>

    </head>

    <body onload="documen t.madlib.adj1.s elect()">

    <FORM NAME="madlib">
    <p>
    adjective:
    <input name="adj1"></p><br>
    <p>
    place:
    <input name="place1"></p><br>
    <p>
    another place:
    <input name="place2"></p><br>
    <p>
    verb:
    <input name="verb1"></p><br>
    <p>
    plural noun:
    <input name="pnoun1"></p><br>
    <p>
    another plural noun:
    <input name="pnoun2"></p><br>
    <p>
    place:
    <input name="place3"></p><br>
    <p>
    adjective:
    <input name="adj2"></p><br>
    <p>
    noun:
    <input name="noun1"></p><br>
    <p>
    verb:
    <input name="verb2"></p><br>
    <p>
    noun:
    <input name="noun2"></p><br>
    <p>
    body part:
    <input name="bpart"></p><br>
    <p>
    verb:
    <input name="verb3"></p><br>
    <p>
    place:
    <input name="place4"></p><br>
    <p>
    verb:
    <input name="verb4"></p><br>
    <p>
    <br>
    <p>

    <INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
    OnClick="displa ymadlib()">

    <INPUT TYPE="reset" VALUE="reset">

    </form>
    </body>

    </html>
    =============== =========
    "Rtritell" <rtritell@aol.c om> wrote in message
    news:2004050617 4818.10191.0000 1008@mb-m14.aol.com...[color=blue]
    > Please can you find out what's wrong, fix the script and tell me what was
    > wrong. Im just beginning
    >
    >
    > <html>
    > <head>
    > <title>Random Mad Lib!</title>
    > <script language="JavaS cript">
    > <!-- Hide
    >
    > function displaymadlib(w 1, w2, w3, w4, w5, w6, w7, w8, w9, w0, w11, w22,[/color]
    w33,[color=blue]
    > w44, w55) {
    >
    > document.writel n("The attack of the purple tissue!!!<br> Once there[/color]
    was[color=blue]
    > a/an "
    > + w1
    > + " tissue attacking a "
    > + w2
    > + " in"
    > + w3
    > + "! The tissue was even"
    > + w4
    > + "the"
    > + w5
    > + "! 4"
    > + w6
    > + "died of heart attacks. The"
    > + w7
    > + "was"
    > + w8
    > + "Suddenly, "
    > + 9
    > + "man came to"
    > + w0
    > + "the"
    > + w11
    > + ". He went up to the tissue and kicked it in the
    > + w22
    > + ", and the tissue"
    > + w33
    > + "to the ground. Its snot covered the "
    > + w44
    > + ", and everything there"
    > + w55
    > + ".");return true
    > }
    >
    > // stop hiding -->
    >
    > </SCRIPT>
    >
    > </head>
    >
    > <body onload="documen t.madlib.adj1.s elect()">
    >
    > <FORM NAME="madlib">
    > <p>
    > adjective:
    > <input name="adj1"></p><br>
    > <p>
    > place:
    > <input name="place1"></p><br>
    > <p>
    > another place:
    > <input name="place2"></p><br>
    > <p>
    > verb:
    > <input name="verb1"></p><br>
    > <p>
    > plural noun:
    > <input name="pnoun1"></p><br>
    > <p>
    > another plural noun:
    > <input name="pnoun2"></p><br>
    > <p>
    > place:
    > <input name="place3"></p><br>
    > <p>
    > adjective:
    > <input name="adj2"></p><br>
    > <p>
    > noun:
    > <input name="noun1"></p><br>
    > <p>
    > verb:
    > <input name="verb2"></p><br>
    > <p>
    > noun:
    > <input name="noun2"></p><br>
    > <p>
    > body part:
    > <input name="bpart"></p><br>
    > <p>
    > verb:
    > <input name="verb3"></p><br>
    > <p>
    > place:
    > <input name="place4"></p><br>
    > <p>
    > verb:
    > <input name="verb4"></p><br>
    > <p>
    > <br>
    > <p>
    >
    > <INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
    > OnClick="displa ymadlib(documen t.madlib.adj1.v alue,
    > document.madlib .place1.value, document.madlib .place2.value,
    > document.madlib .verb1.value, document.madlib .pnoun1.value,
    > document.madlib .pnoun2.value, document.madlib .place3.value,
    > document.madlib .adj2.value, document.madlib .noun1.value,
    > document.madlib .verb2.value, document.madlib .noun2.value,
    > document.madlib .bpart.value, document.madlib .verb3.value,
    > document.madlib .place4.value, document.madlib .verb4.value)">
    >
    > <INPUT TYPE="reset" VALUE="reset">
    >
    > </form>
    > </body>
    >
    > </html>[/color]


    Comment

    • Michael Winter

      #3
      Re: Sorry: its my first script. what is wrong?

      On Fri, 7 May 2004 00:14:29 +0200, Dominique <niques@webadst udio.com>
      wrote:

      Valid HTML documents should have a document type declaration:

      <URL:http://www.w3.org/TR/html4/struct/global.html#h-7.2>
      [color=blue]
      > <html>
      > <head>
      > <title>Random Mad Lib!</title>
      > <script language="JavaS cript">[/color]

      This should read

      <script type="text/javascript">

      The type attribute is required, whereas the language attribute is
      deprecated and should no longer be used.
      [color=blue]
      > <!-- Hide[/color]

      The practice of script hiding is now obsolete. Remove the SGML comment
      delimiters.
      [color=blue]
      > function displaymadlib() {
      > w1 = document.madlib .adj1.value
      > w2 = document.madlib .place1.value,
      > w3 = document.madlib .place2.value
      > w4 = document.madlib .verb1.value
      > w5 = document.madlib .pnoun1.value
      > w6 = document.madlib .pnoun2.value
      > w7 = document.madlib .place3.value
      > w8 = document.madlib .adj2.value
      > w9 = document.madlib .noun1.value
      > w10 = document.madlib .verb2.value
      > w11 = document.madlib .noun2.value
      > w12 = document.madlib .bpart.value
      > w13 = document.madlib .verb3.value
      > w14 = document.madlib .place4.value
      > w15 = document.madlib .verb4.value[/color]

      Why did you decide to create a series of global variables? Use the var
      keyword to keep them local.

      By the way, this would be better written as:

      function displayMadLib( form ) {
      var elems = form.elements;

      // Could use an array rather than separate variables
      var w1 = elems[ 'adj1' ].value,
      w2 = elems[ 'place1' ].value,
      w3 = elems[ 'place2' ].value,
      w4 = elems[ 'verb1' ].value,
      w5 = elems[ 'pnoun1' ].value,
      w6 = elems[ 'pnoun2' ].value,
      w7 = elems[ 'place3' ].value,
      w8 = elems[ 'adj2' ].value,
      w9 = elems[ 'noun1' ].value,
      w10 = elems[ 'verb2' ].value,
      w11 = elems[ 'noun2' ].value,
      w12 = elems[ 'bpart' ].value,
      w13 = elems[ 'verb3' ].value,
      w14 = elems[ 'place4' ].value,
      w15 = elems[ 'verb4' ].value;

      [snip]
      [color=blue]
      > // stop hiding -->[/color]

      Remove this.

      [snip]
      [color=blue]
      > <INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
      > OnClick="displa ymadlib()">[/color]

      This would need to be changed to:

      ... onclick="displa yMadLib(this.fo rm)">

      [snipped top-post]

      Mike


      Please don't top post.

      --
      Michael Winter
      M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

      Comment

      • Dominique

        #4
        Re: Sorry: its my first script. what is wrong?

        lol@mike

        ok... didn't know i was sposed to nail the guy on it... lol*


        "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
        news:opr7loul06 5vklcq@news-text.blueyonder .co.uk...[color=blue]
        > On Fri, 7 May 2004 00:14:29 +0200, Dominique <niques@webadst udio.com>
        > wrote:
        >
        > Valid HTML documents should have a document type declaration:
        >
        > <URL:http://www.w3.org/TR/html4/struct/global.html#h-7.2>
        >[color=green]
        > > <html>
        > > <head>
        > > <title>Random Mad Lib!</title>
        > > <script language="JavaS cript">[/color]
        >
        > This should read
        >
        > <script type="text/javascript">
        >
        > The type attribute is required, whereas the language attribute is
        > deprecated and should no longer be used.
        >[color=green]
        > > <!-- Hide[/color]
        >
        > The practice of script hiding is now obsolete. Remove the SGML comment
        > delimiters.
        >[color=green]
        > > function displaymadlib() {
        > > w1 = document.madlib .adj1.value
        > > w2 = document.madlib .place1.value,
        > > w3 = document.madlib .place2.value
        > > w4 = document.madlib .verb1.value
        > > w5 = document.madlib .pnoun1.value
        > > w6 = document.madlib .pnoun2.value
        > > w7 = document.madlib .place3.value
        > > w8 = document.madlib .adj2.value
        > > w9 = document.madlib .noun1.value
        > > w10 = document.madlib .verb2.value
        > > w11 = document.madlib .noun2.value
        > > w12 = document.madlib .bpart.value
        > > w13 = document.madlib .verb3.value
        > > w14 = document.madlib .place4.value
        > > w15 = document.madlib .verb4.value[/color]
        >
        > Why did you decide to create a series of global variables? Use the var
        > keyword to keep them local.
        >
        > By the way, this would be better written as:
        >
        > function displayMadLib( form ) {
        > var elems = form.elements;
        >
        > // Could use an array rather than separate variables
        > var w1 = elems[ 'adj1' ].value,
        > w2 = elems[ 'place1' ].value,
        > w3 = elems[ 'place2' ].value,
        > w4 = elems[ 'verb1' ].value,
        > w5 = elems[ 'pnoun1' ].value,
        > w6 = elems[ 'pnoun2' ].value,
        > w7 = elems[ 'place3' ].value,
        > w8 = elems[ 'adj2' ].value,
        > w9 = elems[ 'noun1' ].value,
        > w10 = elems[ 'verb2' ].value,
        > w11 = elems[ 'noun2' ].value,
        > w12 = elems[ 'bpart' ].value,
        > w13 = elems[ 'verb3' ].value,
        > w14 = elems[ 'place4' ].value,
        > w15 = elems[ 'verb4' ].value;
        >
        > [snip]
        >[color=green]
        > > // stop hiding -->[/color]
        >
        > Remove this.
        >
        > [snip]
        >[color=green]
        > > <INPUT TYPE="button" NAME="Submit" VALUE="Submit to get your mad lib!"
        > > OnClick="displa ymadlib()">[/color]
        >
        > This would need to be changed to:
        >
        > ... onclick="displa yMadLib(this.fo rm)">
        >
        > [snipped top-post]
        >
        > Mike
        >
        >
        > Please don't top post.
        >
        > --
        > Michael Winter
        > M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)[/color]


        Comment

        • Ron

          #5
          Re: Sorry: its my first script. what is wrong?

          Heya rt,
          I'm going at add a little to Mike's reply in the interest of caution
          when using document.write and document.writel n. It is
          encouraged to use document.open() to let the browser know you're going
          to be creating a new document and document.close( )
          to tell the browser exactly when it can render the new document. My
          browser in particular (Mozilla 1.7b) never "finished" loading the page.
          Also, it's important to be aware that document.write( ) writes the entire
          document.
          In other words, you've left out "<html><head>.. ." etc. and you just have
          a document consisting of "The attack of the purple tissue!...". While many
          browsers will default to wrapping and rendering such a document fragment
          as HTML, it's good practice to give your new document a definite
          document type
          node and a definite core structure:

          var docHeader = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
          // Mike likes HTML4.01, but I prefer introducing the simplicity of XML for new web designers.
          docHeader += "<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.1\/\/EN\" \"http:\/\/www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\ n";
          // Double slashes have to be escaped lest they be mistaken for comments.
          docHeader += "<html xmlns=\"http:\/\/www.w3.org/1999/xhtml\" xml:lang=\"en\" >";
          docHeader += "<head>\n";
          docHeader += "<meta http-equiv=\"Content-Type\" content=\"appli cation/xhtml+xml; charset=iso-8859-1\">\n";
          docHeader += "<title>Ran dom Mad Lib - Your Mad Lib!</title>\n";
          docHeader += "</head>\n";
          docHeader += "<body>\n";
          var docFooter = "</body>\n</html>";
          // The above two variables are good to keep around if you use document.write/ln a lot.



          [snip]

          document.open() ;
          document.write( docHeader);
          document.writel n("The attack of the purple tissue!!!<br> Once there was a/an "
          + w1
          + " tissue attacking a "
          + w2
          + " in"
          + w3
          + "! The tissue was even"
          + w4
          + "the"
          + w5
          + "! 4"
          + w6
          + "died of heart attacks. The"
          + w7
          + "was"
          + w8
          + "Suddenly, "
          + w9
          + "man came to"
          + w10
          + "the"
          + w11
          + ". He went up to the tissue and kicked it in the"
          + w12
          + ", and the tissue"
          + w13
          + "to the ground. Its snot covered the "
          + w14
          + ", and everything there"
          + w15
          + ".");
          document.write( docFooter);
          document.close( );


          Comment

          • Richard Cornford

            #6
            Re: Sorry: its my first script. what is wrong?

            Ron wrote:
            <snip>[color=blue]
            > var docHeader = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
            > // Mike likes HTML4.01, but I prefer introducing the simplicity of
            > XML for new web designers.[/color]
            <snip>

            That is a strange notion in the context of a post discussing the -
            write - method as Mozilla's XHTML DOM does not implement the W3C HTML
            DOM HTMLDocument interface on the document object, and as a result does
            not implement a - write - method at all. So introducing the new web
            designer to XHTML in this context implies abandoning the whole approach
            in favour of the namespace versions of the DOM Core Node manipulation
            methods, for the replacement of the content.

            While I don't agree with the decision not to implement HTMLDocument in
            the XHTML DOM on Mozilla, Mozilla is easily the most widely used browser
            that provides a scriptable DOM for use with XHTML so its implementation
            is significant when considering the subject of scripting XHTML
            documents.

            Richard.


            Comment

            • Ron

              #7
              Re: Sorry: its my first script. what is wrong?

              Richard Cornford wrote:
              [color=blue]
              >[snip]
              >That is a strange notion in the context of a post discussing the -
              >write - method as Mozilla's XHTML DOM does not implement the W3C HTML
              >DOM HTMLDocument interface on the document object, and as a result does
              >not implement a - write - method at all. So introducing the new web
              >designer to XHTML in this context implies abandoning the whole approach
              >in favour of the namespace versions of the DOM Core Node manipulation
              >methods, for the replacement of the content.
              >
              >While I don't agree with the decision not to implement HTMLDocument in
              >the XHTML DOM on Mozilla, Mozilla is easily the most widely used browser
              >that provides a scriptable DOM for use with XHTML so its implementation
              >is significant when considering the subject of scripting XHTML
              >documents.
              >
              >Richard.
              >
              >[/color]
              Heya Richard,
              Interesting, I never noticed that (I've managed to avoid using
              document.write( ) in any of my projects).
              Although it's still listed under the DOM Inspector, I noticed that
              trying to use it just returns an internal context error. Many other
              DOM2 HTML interfaces are still implemented, though. Where can I see a
              specification of Mozilla's XHTML DOM ?

              Comment

              Working...