May 2016. wsurvey_form documentation. The functions in wsurvey_form.js will create a new window (or show an existing container) and write content to it. In particular: a) it will write the contents of a
windowOptions: how to setup the window. saveOptions : how to save values returned from this window Details on arguments windowOptions is optional -- if not specified (or if ''), defaults will be used Recognized fields in windowOptions; winName : the name of the window. If such a window exists, it will be overwritten. Otherwise, a new window will be created. Default value is "viewer" localId : id of container to write to in current window. Default is '' (thus: the default is to use a window with a name of "viewer") Only one of "winName" and "localid" should have a non-'' value! If both are specified, winName is used (stuff is written to a new window) THUS: to use a localId -- you MUST specify winName='' Use of localid can be helpful if you want an "event driven" submission; or if you want to simplify collecting data from a form for an ajax submission. winOptions: Optional. a string containing window options (such as height, toolbar). Basically, the options available in window.open Default values is a resizable window, with no toolbars. saveOptions is optional -- if not specified (or if ''), defaults will be used Recognized fields in saveOptions; callback: a string specifying function to call when form values are saved. If not specified, values will be written to a global variable (see varname below) Otherwise, this function must exist. It will be called with an object containing the values of the elements in the window. See below for details on this object class: a class name of elements whose values should be returned. If not specified, "wsForm" is used names: a csv, or an array, of element "names" whose values should be returned. If not specified, no names are looked for. varname: name of global variable. This is used to store options, AND is used to store returned values. If not specifeid, "wsForm_options" is used submitId: id of a button that, when checked, will return values to the parent window. If not specified, "wsForm_submit" is used submitClass : class of a button (or buttons) that, when checked, will return values to the parent window. If not specified, "wsForm_submit" is used You should specify, in the content, at least one element that has either an id equal to the submitId, or a class equal to submitClass How are values read and returned? The key to using wsForm is to specify, in the content written to the new window, elements that are to be read and returned. There are two ways of doing this: By specifying a matching name in saveOptions.names By specifying a matching class in saveOptions.class. CAUTION: there MUST be a name attribute in elements that have a class match. Basically, if an element in content matches one of the above, its value is returned. And this value depends on the type of the element. There are subtle differences between a "name" match and a "class" match, which are described below. How are values returned? Values are returned using the name of the element. Hence: elements with no name attribute are ignored (even if there is a class match) How is a value determined? It depends on the tagname, and type, of the element: type="checkbox" : If checked: returns its value (its value="..." attribute). If not checked: returns null Special feature: if a not checked, and noCheck attribute is specified, than its value is returned (instead of null) type="radio" : If one of a set of radio buttons, that have the same name, is checked: return its value. Otherwise, return null Special feature: if none of the radio buttons are checked, and noCheck attribute is specified, than its value is returned (instead of null) type="text", or other types : Returns the value (i.e.; text entered in a "text" field)