A5.form.submit Method
Syntax
A5.form.submit(action, formID, url [, additionalParameters]);
Arguments
- actionstring
The name of the action to invoke in the .a5w page that handles the callback. See "Action parameter" section below.
- formIDstring
Thh ID of the form.
- urlstring
The URL of the .a5w page that will handle the callback.
- additionalParametersstring
See "Optional Fourth Parameter" below.
Description
This is the primary function to invoke to submit data from the page back to the server. This action is similar to pressing a submit button on a traditional form, but has additional functionality.
Discussion
There are three required parameters
- action
- formID
- url
Action Parameter
The action has a number of predefined values. All of the actions submit all of the input.
values in controls inside of the specified form element as a POST. The action also submits additional values on every submit.
- __FormAction
This is a variable submitted to define the action taken. Any submit action with place "submit" in this value. Any other action will place the action name, such as 'initialize' in the value.
- __FormID
This is the ID of the firm submitted and matched the 'formID' input parameter.
- a5DirtyRegions
This is the ID of any forms submitted that have 'dirty' values. This will almost always be the same as '__FormID'
- a5RegionsDirtyValues
This is a list of controls that were found to be 'dirty'. This is useful for updates to create update actions to only update field values that have changed.
Submit Actions
- submit:all
This action submits all of the original values in every field prefaced with the pointer 'old.' as well as the current values in every control. The 'old' values can be used in UPDATE statements and other actions if desired.
- submit:dirty
This action is very similar to 'submit:all, except only 'dirty' controls are listed and submitted. Values from 'submit:all' can be evaluated on the callback page to get the same data if required.
- submit:new
This action just submits all current values in the controls. It does not submit the 'old' values.
formID parameter
The formID input specifies the ID of the form element that is being submitted. A single page may have multiple form elements, and it is necessary to indicate which form is being submitted. This value will be in the submitted data as __FormID.
url Parameter
This is the URL of the page to call on submit. This is equivalent to the 'action' attribute of a form element which directs the submit action to open a particular page. This page or "callback" page contains xbasic code to evaluate and manipulate the data submitted. If the data is sent to the page with A5.form.submit(), the page code must test the value in __FormAction to determine what action was invoked. This would be a typical code snippet on the callback page to evaluate what code actions to take after submit.
dim __formAction as c = default "" dim action as c if __formAction = "Submit" then if onFormValidate(local_variables()) afterFormValidate(local_variables()) end if else if __formAction = "Initialize" then onFormInitialize(local_variables()) end if
Note that a second possible input variable ('action') to define an action was specified. This will be examined in A5.ajax.callback().
Optional Fourth Parameter
In some cases, it is desirable to submit values that are not in controls within the specified form. These could be controls in another form element, a fixed value based on some condition, or any other value available to the page. These are the values that would be seen after the "?" in a URL, commonly referred to as the GET or query string. This parameter should have the same syntax as any GET.
For example, if the submit action is submitting to 'calculatesale.a5w' and you want to send additional parameters of 'user=Joe' and 'date=20081010' a normal form element could be:
<form action="calculatesale.a5w.a5w?user=Joe&date=20081010" method="post" name="form1" id="form1">
When using the function A5.form.submit() to submit all values from the form element 'form1', the function syntax would be:
A5.form.submit('submit:new','form1','calculatesale.a5w','user=Joe&date=20081010')