|
|
| The htmlInputHidden class is used to place hidden field data within forms. Hidden fields are not displayed by browsers but are transmitted with other name/value pairs when the form is submitted to a server. Hidden fields are commonly used to embed control data, or to pass state information between pages.
|
|
|
| Note that though hidden fields are not displayed by browsers, they should not be considered secure unless explicitly encrypted. Hidden fields may be viewed by users if they view the HTML source of a page.
|
|
|
| htmlInputHidden objects are used the same as most other form-related input fields. Two versions of the constructor are available, one without any arguments and the other accepting a name and value pair.
|
|
|
| To use hidden fields in a form, construct an htmlInputHidden object and add it to a form using the << operator or the Add() method:
|
| |
|
|
| #include <stdio.h>
|
| #include <stdlib.h>
|
| #include <dcmicro/htmlpp/htmlpp.h>
|
|
|
| int main( void )
|
| {
|
| htmlCgi server ;
|
| htmlPage page ;
|
| htmlForm form( "/cgi-bin/yourapp" ) ;
|
|
|
| form << htmlInputHidden( "customerid", "1234" )
|
| << htmlInputSubmit() ;
|
| page << form ;
|
|
|
| server << page ;
|
| return 0 ;
|
| }
|
|
|
| The above code doesn't do much, but it does illustrate the mechanics of adding a hidden field to a form. When rendered by a browser, the name/value pair describing the customer ID won't be displayed but will be sent to the server when the submit button is pressed.
|
|
|
| When passing form data from one page to another, it's often desirable to include all fields from previous pages in subsequent pages. For forms with more than a few fields, this process would normally be extremely cumbersome -- using the htmlCgi::AsHidden() method makes it easy.
|
|
|
| |