www.webdeveloper.com
Results 1 to 4 of 4

Thread: Web Form Display Entry

  1. #1
    Join Date
    Sep 2006
    Posts
    1

    Web Form Display Entry

    I am sure that this is very simple, but after searching for an hour I wasn't able to find what I was looking for.

    I am trying to display a simple web form that when you click the submit button it will then bring up a new page that displays what was typed into the form. The display would be formatted with css.

    To etter explain what exactly I am trying to do:

    A form would ask:

    Date?:________

    Cheese Name?:________

    Tasting Notes:____________

    And then on submit would create a small sign using the info typed in that is formatted in css.

    Any help would be appreciated.

    Thanks,
    Brandon

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Can't be done with html alone. Use a server side language to process the form data.
    JavaScript can do the same, but server side would be better.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Mar 2010
    Posts
    2,803
    To do it client side maybe use this as a guide.

    set the action parameter to formProcessor.htm

    formProcessor.htm

    Code:
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Form Processor</title>
    </head>
    <body>
    <script type="text/javascript">
    
    if (window != top)
     top.location.href=location.href
    document.write("<h1>Your form has been submitted!</h1><h2>You entered the following data:</h2>");
    var formData = location.search;
    formData = formData.substring(1, formData.length);
    while (formData.indexOf("+") != -1) {
     formData = formData.replace("+", " ");
    }
    formData = unescape(formData);
    var formArray = formData.split("&");
    for (var i=0; i < formArray.length; ++i) {
     document.writeln(formArray[i] + "<br />");
    }
    
    </script>
    </body>
    </html>

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    1) The JavaScript version is not going to work for a great number of users so don't use it.

    2) That example of JavaScript is incompatible with XHTML. In XHTML the content of the SCRIPT element is PCDATA, just like any other element. The parser is still looking for tags so when it hits those in the document.write methods things get wonky. When it hits the less than sign things break. For that reason and others document.write and document.writeln are not supported by XHTML browsers.

    3) That example of JavaScript is also incompatible with HTML. In HTML the SCRIPT and STYLE elements are a special case and they are defined as containing CDATA. The parser stops looking for tags. However, the sign that the CDATA has ended and that it's time for the parser to resume looking for tags is the ETAGO, '</'. And that piece of script contains several of those.

    3) Its not even valid XHTML. The namespace designation is missing.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles