Overview
The Vehicle Form component is dynamically generated for each vehicle based on the number specified in the Client Form. Each form captures motorization type, ITV status, and observations for individual vehicles.HTML Structure
Vehicle forms are dynamically injected into the#formularios container:
- HTML
- CSS
index.html:62
Form Fields
Motorization Radio Buttons
Four mutually exclusive options for vehicle engine type:- Diesel (
value="Diesel") - ID:radio1{N} - Gasolina (
value="Gasolina") - ID:radio2{N} - Hibrido (
value="Hibrido") - ID:radio3{N} - Electrico (
value="Electrico") - ID:radio4{N}
name attribute: motorizacion{N} where {N} is the vehicle number.
Validation: Required field (script.js:169-174)
ITV Status Radio Buttons
Two mutually exclusive options for inspection status:- Aprobado (
value="Aprobo") - ID:radio5{N} - No Aprobado (
value="NoAprobo") - ID:radio6{N}
name attribute: aprobados{N} where {N} is the vehicle number.
Validation: Required field (script.js:177-181)
Observations Textarea
- ID:
observaciones{N}where{N}is the vehicle number - Max length: 250 characters
- Rows: 4
- Required: No
- Purpose: Free-form text for vehicle condition notes
Related Functions
crearFormularioVehiculo(numeroVehiculo)
Generates the HTML structure for a single vehicle form.script.js:58-102
numeroVehiculo(number): The vehicle number (1-indexed)
string - HTML string for the vehicle form
generarFormulariosVehiculos()
Generates all vehicle forms based on the globalnumeroAutos variable.
script.js:44-51
numeroAutos)
Returns: void
Behavior: Iterates from 1 to numeroAutos and appends each vehicle form to the container
validarFormulariosVehiculos()
Validates that all vehicle forms have required fields completed.script.js:167-184
boolean - true if all forms are valid, false otherwise
Behavior:
- Checks each vehicle form has a motorization selected
- Checks each vehicle form has an ITV status selected
- Shows error message for first missing field found
- Returns
falseimmediately on first validation failure
procesarDatosVehiculos()
Extracts and stores data from all vehicle forms into the globalvehiculosData array.
script.js:189-204
vehiculosData array with vehicle data objects
Data Structure:
agregarBotonCalcular()
Adds the calculation button after all vehicle forms.script.js:107-114
CSS Classes
.formulario
Grid container for all vehicle forms.styles.css:173-178
.bloque
Container for individual vehicle form.styles.css:180-193
.aprobados
Special container for ITV status radio buttons with green theme.styles.css:248-267
.caja-texto
Styled textarea for vehicle observations.styles.css:270-288
Usage Example
Pricing by Motorization
The vehicle forms feed into the pricing calculation:| Motorization | Price (€) | Variable |
|---|---|---|
| Diesel | 50 | tarifas.Diesel (script.js:270) |
| Gasolina | 45 | tarifas.Gasolina (script.js:271) |
| Hibrido | 35 | tarifas.Hibrido (script.js:272) |
| Electrico | 30 | tarifas.Electrico (script.js:273) |
Validation Rules
| Field | Rule | Error Message |
|---|---|---|
| Motorization | One option must be selected | ”Por favor, seleccione la motorización para el vehículo .” |
| ITV Status | One option must be selected | ”Por favor, seleccione el estado ITV para el vehículo .” |
| Observations | Optional, max 250 chars | None |
Responsive Behavior
- Desktop (>768px): Auto-fit grid with multiple columns
- Tablet (768px): Single column (styles.css:444-447)
- Mobile (<480px): Reduced padding (styles.css:469-478)
Animations
Vehicle forms animate in with a fade-in effect:styles.css:411-428