Placed in the Default Value area of a field. This can be particularly useful when using the form inside a module or inside an article and you wish to know from where it was submitted:
//<code> $doc = JFactory::getDocument(); return $doc->getTitle(); //</code>
This scenario assumes the use of two form components, a hidden field component and a freetext component. You should place the following script within a freetext:
For the script to work properly you will have to replace hidden_field_name with your hidden field component exact name. When the form is submitted, the page title will be stored in the hidden field (the page title will not show within the form in the frontend area).