Это результаты отображения на основе идентификатора < /p>
Код: Выделить всё
function displayResults(data) {
var resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '';
if (data.length === 0) {
resultsDiv.innerHTML = '
No se encontraron pacientes con los criterios de búsqueda.
';
} else {
data.forEach(function(patient) {
resultsDiv.innerHTML += '
ID: ' + patient.id + '
' +
'
Nombre: ' + patient.nombre + '
' +
'
Apellido: ' + patient.apellido + '
' +
'
DNI: ' + patient.dni + '
' +
'
Teléfono: ' + patient.telefono + '
' +
'
Dirección: ' + patient.direccion + '
' +
'
Género: ' + patient.genero + '
' +
'
Edad: ' + patient.edad + '
' +
'Modificar' +
'Eliminar';
});
}
}
< /code>
И это функция, которая вызывается из сценария .gs < /p>
function showModifyForm(patientId) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Pacientes");
var data = sheet.getDataRange().getValues();
var patientData = null;
// Buscar el paciente por ID
for (var i = 1; i < data.length; i++) {
if (data[i][0] == patientId) {
patientData = data[i];
break;
}
}
if (patientData) {
// Pasamos los datos al HTML para pre-llenar el formulario
var htmlOutput = HtmlService.createHtmlOutputFromFile('ModifyForm');
htmlOutput.append("var patientData = " + JSON.stringify(patientData) + ";");
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Modificar Paciente');
} else {
SpreadsheetApp.getUi().alert('No se encontró el paciente con ese ID');
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... rrect-when
Мобильная версия