My goal is to extract values from name-value pairs within a URL and return those values into a string that can be inserted into a web tracking tag. Th using a js function. The string has fifteen positions separated by "-_-". No matter where each name-value pair appears within the URL, values most always be inserted into the same position within the tracking tag string. For example, the value(s) for the name apple must always appear in the first position, the value(s) for the name banana must always appear in the second position, and the value(s) for the name watermelon must always appear in the fifth position.
The URL will have a pound sign followed by an indefinite number of name-value pairs (up to 15). The name value pairs, connectors, and separators are encoded. Values are strings that may be joined by "+" symbol. Finally, Names may appear multiple times within the URL, each time with a different value. However, since names only exactly one corresponding spot within the tracking tag string, the associated values must be joined into the same position (using "+").
Example URL:
http:www.mysite.com#currentPage=1&c%5B%5D=e%3A1119//e+apple//%3Aeq//red&c%5B%5D=e%3A1119//e+banana//%3Aeq//yellow+black&c%5B%5D=e%3A1119//e+watermelon//%3Aeq//red&c%5B%5D=e%3A1119//e+watermelon//%3Aeq//black
Example function using the tracking tag string created from above:
cmCreateElementTag("Tracking Parent", "Tracking Child","red-_-yellow+black-_--_--_-red+black-_--_--_--_--_--_--_--_--_--_-");
I'd like to use jquery to extract the values from the URL and place them in the right position within the tracking tag string.