Using Components > Writing change handler functions for components > Multiple-selection forms |
![]() ![]() ![]() |
Multiple-selection forms
In a form where the user makes multiple inputs or selections using various components and then submits the completed form, you need only specify a function for the Change Handler parameter for the component responsible for submitting the form data and exiting the form. The function needs to accept an instance of the component as a parameter, create an object with properties for storing the data, specify actions for gathering the data from all of the components in the form, and then perform an output, submit, or exit page action.
The following example is an onClick
function specified for a Submit button on a form that has a check box, a group of radio buttons, and a list box. The user makes choices before pressing the Submit button to submit the form. The labels of the selected components are written to the Output window.
function onClick( component ) { if ( component._name == "submit"){ // create the object to store values formData = new Object(); formdata.checkValue = ""; formData.radioValue = ""; formData.listValue = ""; // gather the data formData.checkValue = checkBox_mc.getValue(); formData.radioValue = radioGroup.getValue(); formData.listValue = listBox_mc.getValue(); // output the results trace(formData.listValue); trace(formData.radioValue); trace(formData.checkValue); } }
![]() ![]() ![]() |