Overview
The form generation API provides functions to dynamically create and manage vehicle inspection forms based on the number of vehicles specified by the user.enviar()
Main entry point for generating vehicle forms. Validates client data and creates dynamic vehicle forms. Source:script.js:8-39
Parameters
This function takes no parameters. It reads values directly from the DOM.Returns
void - Does not return a value
Side Effects
- Validates client information fields (nombre, apellidos, razonSocial, nAutos)
- Clears previous forms from the DOM
- Resets the
vehiculosDataglobal array - Generates new vehicle forms
- Adds a calculate button
- Shows loading animation
Validation Rules
All client fields (nombre, apellidos, razonSocial, nAutos) are required. The number of vehicles must be between 1 and 50.
Example Implementation
Usage
generarFormulariosVehiculos()
Generates individual forms for each vehicle based on the globalnumeroAutos variable.
Source: script.js:44-51
Parameters
This function takes no parameters. It uses the globalnumeroAutos variable.
Returns
void - Does not return a value
Side Effects
- Appends vehicle form HTML to the
#formularioscontainer - Creates one form per vehicle (loop from 1 to
numeroAutos)
Example Implementation
crearFormularioVehiculo()
Creates the HTML structure for a single vehicle inspection form. Source:script.js:58-102
Parameters
The vehicle number (1-indexed) used to generate unique IDs and labels
Returns
string - HTML string containing the complete vehicle form structure
Form Structure
Each vehicle form includes:- Motorization options: Diesel, Gasolina, Híbrido, Eléctrico (radio buttons)
- ITV Status: Aprobado, No Aprobado (radio buttons)
- Observations: Textarea with 250 character limit
All radio button groups use unique names based on the vehicle number (e.g.,
motorizacion1, motorizacion2) to ensure proper form behavior.Example Implementation
Usage
agregarBotonCalcular()
Appends the calculate button to the forms container after all vehicle forms have been generated. Source:script.js:107-114
Parameters
This function takes no parameters.Returns
void - Does not return a value
Side Effects
- Appends a button element to the
#formularioscontainer - Button spans full grid width and is centered
Example Implementation
The button calls
calcularYMostrar() which validates, calculates, and displays results.mostrarAnimacionCarga()
Displays a loading animation on the submit button while forms are being generated. Source:script.js:469-482
Parameters
This function takes no parameters.Returns
void - Does not return a value
Side Effects
- Adds
loadingclass to the submit button - Changes button text to ”⏳ Generando formularios…”
- Disables the button for 1 second
- Restores original state after timeout
Example Implementation
Global Variables
numeroAutos
Type:numberSource:
script.js:2
Stores the total number of vehicles to process. Set by the enviar() function.
vehiculosData
Type:Array<Object>Source:
script.js:3
Stores processed vehicle data. Each object contains:
numero(number): Vehicle numbermotorizacion(string): Type of engineestadoITV(string): ITV statusobservaciones(string): Vehicle observations
Related Functions
- Data Validation - Validate form inputs
- Calculation Engine - Process and calculate results
- Export Functions - Export form data