Changes

Jump to: navigation, search

Show/Hide Header

1,293 bytes added, 19:36, 10 February 2016
the code supplied does not work, and breaks smartfields spaces removed and semi colon added
==Overview=={{JavaScript Syntax}}The '''showhideheader''' function allows you to use one [[Custom Field]] (the '''Control''' field) to show or hide all [[Custom Fields]] that are located under a [[Custom Field Type: Title Bar – Multiple Columns|Title Bar Field]]
This is a new feature designed to support more dynamic pages by providing for control of * All fields between the specified [[Custom Field Type: Title Bar – Multiple Columns|Title Bar Field]] and the visibility of subsequent [[Custom FieldsField Type: Title Bar – Multiple Columns|custom fieldsTitle Bar Field]] through values that are entered elsewhere will have their visibility controlled as a group.* The set of fields being hidden can be located anywhere on the same page.* '''Note:''' The [[Custom Field Type: Title Bar – Multiple Columns|Title Bar Field]] must <u>not</u> have '''Use As Tab''' enabled. (In other words it cannot be a [[Custom Field Tab]]).
The concept is that one [[Custom Fields|custom field]] - the "control field" - is used to control the display of a set of [[Custom Fields|custom fields]] based on a value entered or selected in the control field.
The control field can be any type of [[Custom Fields|custom fieldField]] that can contain contains a value such as a text box (:* [[Custom Field Type (30): Text – Single Line|single]] or * [[Custom Field Type (40): Text – Multiple Lines|multiple]] line), * [[Custom Field Type (10): Select One – Combo Box|Combo box - select one]], * [[Custom Field Type (20): Select Many – Check Boxes]] ''(Note: see [[#Check Boxes|Check boxes - select manybelow]], )''* [[Custom Field Type (60): Special – Calculated Value|Calculated field]] or * [[Custom Field Type: Lookup – Entity and People]]* [[Custom Field Type: Lookup – External Entity]]* [[Custom Field Type: Lookup type field.– External People]]
The only field types that cannot be used are fields such as [[Custom Field Type (103): Special – Browser Script|browser script]], [[Custom Field Type: Display Only – Image|Image]] field, etc.
 
The controlled fields must all be placed under a '''Title Bar''' type field.
 
==Example==
==Syntax==
Place the following code in the '''HTML Tag''' box of the '''Control''' field:
:<prefont size="3">onchange="_showhideheader(xxxxxx,this.value=='Yes')"</prefont>
'''Where ''':* ''xxxxxx''' is the field ID of the '''[[Custom Field Type: Title Bar – Multiple Columns|Title Bar]] field that you wish to control.* ''Yes'' is the value in the control field that you wish to controluse to trigger the display of '''Title''' '''Bar''' and the other '''Controlled''' fields in the block.
Where '''YesNote:''' is the value in the control field that you wish to [[Custom Field Type: Select Many – Check Boxes|Check Boxes]] use to trigger the display of '''Title''' '''Bar''' and the other '''Controlled''' fields in the blocka different syntax.See [[#Check Boxes|below]]
'''More complex syntax can also be used:'''
<pre>'''Examples:'''* Display the controlled fields when the control field (Custom Field ID 123456) is '''not equal''' to Yes: onchange="_showhideheader(123456,this.value!='Yes')"
onchange="_showhideheader(xxxxxx,this.value!='Yes')"
Display the controlled fields when * '''Multiple Conditions''' the control field (Custom Field ID 123456) is not equal to either Yes or Maybe: onchange="_showhideheader(123456,(this.value=='Yes' || this.value=='Maybe'))"
onchange="_showhideheader(xxxxxx,(this.value=='Yes' || this.value=='Maybe'))"
* Display the controlled fields when the control field (Custom Field ID 123456) is either Yes or Maybe'''empty''': onchange="_showhideheader(123456,this.value==''''''')"
onchange="_showhideheader(xxxxxx,this.value==''")
*Display the controlled fields when the a '''numerical''' control field (Custom Field ID 123456) is emptygreater than 6: onchange="_showhideheader(123456, parseInt(this.value ) >6)"
==Multiple Title Bars=='''Multiple headers''' can be hidden/shown simultaneously::<font size="3">onchange="_showhideheader(xxxxxx, parseIntthis.value=='A');_showhideheader(yyyyyy,this.value =='B') ;" </font>6)"
Display This will display the controlled fields under '''Title Bar''' xxxxxx when the control field is greater than 6has value '''A''' and display the fields under '''Title Bar''' yyyyyy when the control field has value '''B'''. </pre>
If there are ==Check Boxes==When the '''Control''' field is a set of fields that are required to be displayed and others to be kept hidden based on values selected from combo box, following syntax may be used[[Custom Field Type:<pre>onchange="_showhideheader(xxxxxxSelect Many – Check Boxes|Select Many Check Box]],this.value=you will need to use the '''Aonclick') ;_showhideheader(yyyyyyy,this.value='B') " syntax.
Display the controlled fields associated with '''Title Bar''' type field ID xxxxxx when the control field is A anddisplay controlled fields associated with '''Title Bar':<font size="3">onclick="_showhideheadercheckbox(xxxxxxx,this,'Yes;Cancel' type field ID yyyyyyy when the control field is B)"</prefont>
* Use '''onclick''' instead of '''onchange'''
* Use '''this''' instead of '''this.value'''
* ''''Yes;Cancel'''' - values delimited by semi-colon
'''**'''When the '''Control''' field is a '''Select Many Check Box''', you will need to use the onclick syntax. Please see the [[Show/Hide Fields Using a Check Box]] article.
The difference between '''Example:'''* Using a select many check box, but allowing only one value to be selected and controlling the showhideheader if the value is '''equal''' to Yes: onclick="onlyonechecked(this feature and [[Custom Field Type ); _showhideheader(87123456,this.value=='Yes'): Dynamic Data – Dynamic Control Field|Dynamic Control]] field is that:"
Unlike ==Notes==The difference between this feature and [[Custom Field Type: Dynamic Data – Dynamic Control Field|Dynamic Control Field]] is that:* The set of fields that you wish to control can be located anywhere on the page. With [[Custom Field Type (87): Dynamic Data – Dynamic Control Field|DynamicControl Fields]] the fields must be below the control field. * Unlike the [[Custom Field Type: Dynamic Data – Dynamic Control Field|custom fieldDynamic Control Field]], there are no fields "nested" within the control field .* The fields hidden by one control can be used as control fields themselves. Using nested [[Custom Field Type: Dynamic Data – Dynamic Control Field|Dynamic Control Fields]] (dynamic controls within dynamic controls) is not recommended, and you cannot report below the set first level of nested fields that you wish .* If using '''[[Allowing Only One Check Box to control can be located anywhere Selected|onlyonechecked]]''' on the page.a [[Custom Field Type: Select Many – Check Boxes|Select Many - Check Box]] field and you also want to Show/Hide Header you should use '''_showhideheader''' instead of '''_showhideheadercheckbox'''
Using nested ==See Also==* [[Custom Field Type (87): Dynamic Data – Dynamic Control Field|Dynamic ControlMaking a field under a show/hide header mandatory]] fields (dynamic controls within dynamic controls) you cannot report below the first level * [[Conditional Lists of nested fields.Values]]{{VisibilityofCustomFields}}
[[Category:Custom Fields]][[Category:Enhancements]][[Category:System Management]][[Category:JavaScript Examples]]
Smartstaff, administrator
3,321
edits

Navigation menu