Problem

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

    Problem

    Hello
    I've got: file 'name.html', where are:

    <BODY>
    <center>
    <form type=get action="to.html ">
    <table border=1>
    <tr>
    <td>First Name:</td><td><input type=text name=firstname size=10></td>
    </tr>
    <tr>
    <td>Last Name:</td><td><input type=text name=lastname size=10></td>
    </tr>
    <tr>
    <td>Age:</td><td><input type=text name=age size=3></td>
    </tr>
    <tr>
    <td colspan=2><inpu t type=submit value="Submit!" >
    </td>
    </tr>
    </table>
    </form>
    </center>
    </body>

    in the secound file 'name1.html':

    <html>
    <HEAD>

    <SCRIPT LANGUAGE="JavaS cript">

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    <!-- Begin
    function getParams() {
    var idx = document.URL.in dexOf('?');
    var params = new Array();
    if (idx != -1) {
    var pairs = document.URL.su bstring(idx+1, document.URL.le ngth).split('&' );
    for (var i=0; i<pairs.length ; i++) {
    nameVal = pairs[i].split('=');
    params[nameVal[0]] = nameVal[1];
    }
    }
    return params;
    }
    params = getParams();
    // End -->
    </script>
    </HEAD>
    <BODY>

    <SCRIPT LANGUAGE="JavaS cript">

    <!-- Begin
    firstname = unescape(params["firstname"]);
    lastname = unescape(params["lastname"]);
    age = unescape(params["age"]);

    document.write( "firstname = " + firstname + "<br>");
    document.write( "lastname = " + lastname + "<br>");
    document.write( "age = " + age + "<br>");
    // End -->
    </script>
    </body>
    </html>

    When I start my scripts and give values, in name1.html there is text:
    undefined. Why? What's wrong?
    qpon



  • Michael Winter

    #2
    Re: Problem

    On Sun, 8 Aug 2004 13:50:44 +0200, qpon <qpon.sNOSPAM@i nteria.pl> wrote:
    [color=blue]
    > Hello
    > I've got: file 'name.html', where are:
    >
    > <BODY>
    > <center>[/color]

    This element is deprecated. You should catch up with the times and use
    Cascading Style Sheets (CSS) for presentation. See the
    comp.infosystem s.www.authoring.stylesheets newsgroup for help with CSS. Be
    sure to read the FAQ before posting, though.

    <URL:http://www.faqs.org/faqs/www/stylesheets/newsgroup-faq/>
    [color=blue]
    > <form type=get action="to.html ">[/color]

    This is your problem. The FORM element does not have a type attribute.
    What you actually want is the method attribute. Also, you use to.html as
    the destination, but you refer to name1.html below. Try:

    <form action="name1.h tml" method="get">

    Had you validated your HTML (see <URL:http://validator.w3.or g/>), you
    would have noticed this.

    [snip]
    [color=blue]
    > <SCRIPT LANGUAGE="JavaS cript">[/color]

    Valid HTML requires the type attribute. This attribute renders the
    deprecated language attribute obsolete.

    <script type="text/javascript">
    [color=blue]
    > <!-- This script and many more are available free online at -->
    > <!-- The JavaScript Source!! http://javascript.internet.com -->
    >
    > <!-- Begin[/color]

    Hiding script data with SGML comment delimiters is an out-dated practice
    that should have disappears years ago. All browsers in use understand the
    SCRIPT element, even if they don't execute scripts.
    [color=blue]
    > function getParams() {
    > var idx = document.URL.in dexOf('?');
    > var params = new Array();
    > if (idx != -1) {
    > var pairs = document.URL.su bstring(idx+1,
    > document.URL.le ngth).split('&' );
    > for (var i=0; i<pairs.length ; i++) {
    > nameVal = pairs[i].split('=');
    > params[nameVal[0]] = nameVal[1];
    > }
    > }
    > return params;
    > }
    > params = getParams();[/color]

    I really don't like how that's written, but I don't really have time to
    change it now. Hopefully, someone else will.
    [color=blue]
    > // End -->[/color]

    This should go, too.
    [color=blue]
    > </script>
    > </HEAD>
    > <BODY>
    >
    > <SCRIPT LANGUAGE="JavaS cript">
    >
    > <!-- Begin[/color]

    [snip]
    [color=blue]
    > // End -->[/color]

    Same comments regarding obsolesence apply here, too.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail

    Comment

    • qpon

      #3
      Re: Problem

      Try:[color=blue]
      > <form action="name1.h tml" method="get">[/color]

      It doesn't work!



      Comment

      • Andrew Thompson

        #4
        Re: Problem

        On Sun, 8 Aug 2004 22:01:11 +0200, qpon wrote:
        [color=blue][color=green]
        >> <form action="name1.h tml" method="get">[/color]
        >
        > It doesn't work![/color]

        ....err. Did you try it as?

        <form action="to.html " method="get">

        [ Failing that, try flogging it with
        a whip, it might just be lazy. ;-) ]

        --
        Andrew Thompson
        http://www.PhySci.org/ Open-source software suite
        http://www.PhySci.org/codes/ Web & IT Help
        http://www.1point1C.org/ Science & Technology

        Comment

        • qpon

          #5
          Re: Problem

          > ...err. Did you try it as?

          Know it works!
          Thanks of all


          Comment

          Working...