Changes

Jump to: navigation, search

Passing Values Using Parameters

310 bytes added, 17:39, 20 October 2017
no edit summary
Using several techniques , you can pass values a value (called a Parameter) from one page to another in order to pre-populate form fields or display on an HTML page.
==Sending Page==
Values can be sent from the initial (sending) page by creating a link to the destination page that includes parameter parameters linking the variables to be passed. These are then parsed by the receiving page back into values.
'''PortalSyntax:''':<font size="3">'''/urltopage?var1=@variable1@&var2=@variable2@'''</font>  '''Where:'''* Create a ''urltopage'' is the relative [[PortalURL]] shortcut and associate to the link with that shortcutdestination page.* ''variable1'', ''variable2'' etc. are the variable names (e.g. @firstname@).* ''var1'', ''var1'' corresponding names for the variables
<pre>
/urltopage?parameter1=@variable1@&parameter2=@variable2@
</pre>
User and Company variables can be used to pass the current logged in user details and their company details.<u>'''Examples:'''</u>
'''ApplicationPortal'''* Create a [[Custom FieldPortal]] of shortcut and associate the type [[Custom Field Type: Read Only – System Variables|Read Only - System Variables]] link with one of the followingthat shortcut. /urltopage?var1=@variable1@&var2=@variable2@
'''Display as buttonButton'''* Create a [[Custom Field Type: Read Only – System Variables|Read Only - System Variables]] Custom Field with:
<pre>
<input type="button" class=Button value="Button Label" onClick='parent.location.href="/urltopage?parameter1var1=@variable1@&parameter2var2=@variable2@"'/>
</pre>
 '''Display as hyperlinkHyperlink'''* Create a [[Custom Field Type: Read Only – System Variables|Read Only - System Variables]] Custom Field with:
<pre>
<a href="/urltopage?parameter1var1=@variable1@&parameter2var2=@variable2@">Click Here</a>
</pre>
Replace "variable1" with '''Note''': User and Company variables can be used to pass the actual variable name current logged in user details and "parameter1" with a corresponding name (eg. firstname=@firtsname@)their company details.   
==Receiving Page==
Place one of the following second functions in within the bodyjust prior to the closing body tag (&lt;/body>).
var para2=document.getElementById('field2');
para1.value = unescape(params["parameter1var1"]);para2.value = unescape(params["parameter2var2"]);
var para2=document.getElementById('element2');
para1.value = unescape(params["parameter1var1"]);para2.value = unescape(params["parameter2var2"]);
</script>
Replace "field1" or "element1" etc. with the actual form or element id name and "parameter1var1" with the parameter name.
eg.
[[SmartSimple]] will replace the variable references (@lastname@ , etc.) with values derived from the current [[User|user]] session. 
[[Category:JavaScript]]
==See Also==* [[Category:System Management]][[Category:JavaScript]][[Category:Pass VariablesTo Level 1]]
Smartstaff, administrator
686
edits

Navigation menu