Skip to main content
Kinetic Community

Get parameters from the URL

Sometimes it is useful  to included parameters(values) in the URL.  This allows the Service Item to be opened while passing values into it.  These values can be used by logic upon opening of the Service Item.  For example you may want to pre-populate a question with a value.  You can pass a parameter in the URL for the Service Item and the value can be used immediately.

Resolution

Example:

In this example we want to pass a value of "blue" into the Service Item and display it in an alert message.

Insert javascript (usually in a custom event to execute on load) similar to below.

var testParameter = KD.utils.Util.getParameter('color1');
alert(testParameter);

In the example, the variable testParameter is set to the value of the 'color1' parameter in the URL. The parameter name 'color1' has been chosen for this example.  Any name may be given to the parameter it just must match what is passed into the KD.utils.Util.getParameter function.

Now add the parameter to the URL.  Here is where the parameter name 'test' would be given a value of 'blue.  It is done by adding to the URL  '&color1=blue'.  Additional parameters may be added by adding another '&', the parameter name and value.

When the code executes on load, an alert message will be displayed with the value of 'color1'.  In this case it is blue.

Example URLs:

http://matrix.kineticmatrix.com/kinetic/DisplayPage?srv=KS000c29724a16kUpNTg8GS7UwBK3V&color1=blue

http://matrix.kineticmatrix.com/kinetic/DisplayPage?srv=KS000c29724a16kUpNTg8GS7UwBK3V&color1=blue&color2=red