Estoy tratando de crear un tablero simple donde, si el usuario accede a su tablero, mostrará datos de la hoja de cálculo de Google. Pero hay un problema, no sé por qué solo mi primer div obtiene el objetivo a través de JavaScript, no el segundo ...
cualquier ayuda y solución sería apropiada ...
¿Por qué mi segmentación de segunda línea div id="load1" no se está ejecutando?
Código.gs
`function loadDetails(id){ var ss = SpreadsheetApp.openById("14RM_170AefKbQq82NXAdSOemQLyAGcv_BTwYWd1-qtM") var ws = ss.getSheetByName("Data") var data = ws.getDataRange().getValues() for(var i=0; i<data.length; i++){ var row = data[i] if(row[0]== id){ password = { psd: row[1], id: row[0] } } } if(row[0]!= id){ password = "not found" } return password; }`Tablero.HTML
<!DOCTYPE html> <html> <head> <base target="_top"> </head> <body> <h1>Hey this is other Employee Dashboard</h1> <p>Your Employee Id: = </p> <p>Your Password : = </P> <div id="load"> <div> <div id="load1"> <div> <script> window.onload = function(){ var id = "MN00018" google.script.run.withSuccessHandler(function(output){ document.getElementById("load").innerHTML = `passing objects are ${output.psd} & ${output.id}` document.getElementById("load1").innerHTML = `passing objects are ${output.id}` }).loadDetails(id) } </script> </body> </html>Si realmente está probando su secuencia de comandos, creo que hay 2 puntos de modificación.
La etiqueta de div no está incluida. ¿Qué hay de modificar de la siguiente manera?
<div id="load"> <div> <div id="load1"> <div> <div id="load"> </div> <div id="load1"> </div>Why My Second Line Targeting div id="load1" is not executing ???? . En el lado de Google Apps Script, por if(row[0]!= id){password = "not found"} , incluso cuando se encuentra el id de la columna "A", se devuelve "not found". ¿Qué hay de modificar de la siguiente manera?
function loadDetails(id) { var ss = SpreadsheetApp.openById("###"); var ws = ss.getSheetByName("Data") var data = ws.getDataRange().getValues() var password = {psd: "", id: ""}; for (var i = 0; i < data.length; i++) { var row = data[i] if (row[0] == id) { password = { psd: row[1], id: row[0] } break; } } return password; }