Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
This course introduces web designers to the nuts and bolts of HTML (HyperText Markup Language), the programming language used to create web pages. Author Bill Weinman explains what HTML is, how it's structured, and presents the major tags and features of the language. Discover how to format text and lists, add images and flow text around them, link to other pages and sites, embed audio and video, and create HTML forms. Additional tutorials cover the new elements in HTML5, the latest version of HTML, and prepare you to start working with Cascading Style Sheets (CSS).
One of the main problems with the way we bpages, work and indeed a problem with the HTTP protocol, is that it's stateless. Every time you send a form response to a server it's a completely new connection and the server has no indication of the context of your session. There is typically no identifying information in the connection to indicate that it's related to another recent connection. To make matters even worse, there could be a number of users using different sessions on the same resource, all from the same IP address or a proxy server.
Of course, this is why HTTP cookies were invented, but for many uses there's a simpler solution. HTML form supports an invisible element called hidden, sometimes called hidden fields. Let's see how this works. I am going to make a working copy of forms.html and we are going to rename this to forms-working.html. I am going to open this in the text editor here. You'll notice it's using the same forms.css and forms.js that we've been using throughout this chapter. And I'm going to go ahead and open this in our browser as well, and we'll open this with Firefox.
Here's our little form, and you notice that it has a text field, a password field, some checkboxes, and a set of radio buttons. And when I fill it out and press the Big Red Button, you'll notice that we get all of those values. Now we can add to this, and I'm just going to put it down here, and it's not going to go in a paragraph or anything because it doesn't actually display. We can put in some hidden elements. And these are constructed, again, with input. In this case, it's type="hidden," and we can give it a name.
Let's call this one userid and a value="12345," and I'm just going to copy this, give it a few more here. Let's see. We'll have a page and an action and a color, blue, right? Now when I save this and come back over here to our browser--I'm going to reload and I'm just going to press the Big Red Button here-- you'll notice that these hidden fields, we actually get these named/value pairs, and that works the same obviously when you submit it to a CGI script on a server.
And so using these hidden fields, you could keep track of a session. You can keep track of userid. And the other great thing about them as opposed to the cookies, is that these are entirely not persistent, so when this session is done, these are gone and nobody is keeping track of anybody. Of course, if you want to on the other end, you can keep a database. You can have a cookie for your userid. I mean you can use a combination of technologies, but these are a beautiful way of just keeping context of a session between pages in a CGI scripting application.
So, hidden fields are great way to keep context in this session. Unlike cookies, they can be coded right in your HTML and they're not persistent. They can be generated by a script, and they work really well for keeping track of CGI sessions.
Find answers to the most frequently asked questions about HTML Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.