Adds any number of attribute/value pairs to a query string.

Syntax

JSV_queryString(expS, expA, expV, ...)

Prototype

expS.queryString(expA, expV, ...)

Returns

The query string with the new attribute/value pairs added.

Parameters

The queryString function uses the following arguments.

Argument Description
expS The initial query string.
expA Attribute to be added to the query string.
expV Value of the attribute being added.

Remarks

Any number of attribute/value pairs may be passed to the JSV_queryString function. This function implements the following rules:

  1. All values are escaped. (See example 1)
  2. If an attribute/value pair is passed and the value is empty, then the attribute/value pair is not written into the query string. (See example 2)
  3. If the attributes and values passed are not paired, then the last argument passed is not written into the query string. (See example 3)

Dependencies

JSV_isWhitespace

Example

The following lines of code

var qs = '';
var cfPage = "MyDocument.cfm";
document.write( "Example 1: " + 
    cfPage + 
    JSV_queryString(qs, "One", 100, "Apple", "Red", "Music", "R&B") );
document.write( "Example 2: " + 
    cfPage + 
    JSV_queryString(qs, "One", 1, "Apple", "", "Music", "R&B") );
document.write( "Example 3: " + 
    cfPage + 
    JSV_queryString(qs, "One", 1, "Music", "Scene", "Groove") );

produce