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
08-29-2010, 02:20 AM
Fang
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.
08-29-2010, 02:31 AM
tirna
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>
08-29-2010, 11:58 AM
Charles
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.