Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
Enviar el parámetro de elemento de botón de radio "este" para que funcione en el script de Google Apps

Tengo una barra lateral personalizada generada a través de Apps Script en una hoja de Google.

El HTML de la barra lateral personalizada contiene un formulario y un conjunto de campos con 5 elementos de entrada de radio, todos con eventos de cambio:

 google.script.run.viewOptionsFormRadioChange(this);

Aquí está el formulario HTML completo:

 <form id="viewOptionsForm"> <fieldset class="viewOptionsFieldset"> <input type="radio" id="all" name="viewOptionsRadio" value="All" checked="checked" onchange='google.script.run.viewOptionsFormRadioChange(this);' > <label for="all">All</label><br> <input type="radio" id="firstImport" name="viewOptionsRadio" value="First Import" onchange='google.script.run.viewOptionsFormRadioChange(this);'> <label for="firstImport">First Import</label><br> <input type="radio" id="secondImport" name="viewOptionsRadio" value="Second Import" onchange='google.script.run.viewOptionsFormRadioChange(this);'> <label for="secondImport">Second Import</label><br> <input type="radio" id="compositionLinking" name="viewOptionsRadio" value="Composition Linking" onchange='google.script.run.viewOptionsFormRadioChange(this);'> <label for="compositionLinking">Composition Linking</label><br> <input type="radio" id="underTheHood" name="viewOptionsRadio" value="Under the Hood" onchange='google.script.run.viewOptionsFormRadioChange(this);'> <label for="underTheHood">Under the Hood</label> </fieldset> </form>

Luego tengo una función "viewOptionsFormRadioChange":

 function viewOptionsFormRadioChange(checkbox) { if(checkbox.checked == true){ if(checkbox.attr('id') == "underTheHood") { SpreadsheetApp.getActive().toast("underTheHood Selected", "Title", 15); } } }

Estoy tratando de obtenerlo para que aparezca la notificación de brindis cuando selecciono el botón de opción Bajo el capó, sin embargo, el parámetro del elemento "este" no parece aparecer como variable de parámetro: casilla de verificación ya que lo anterior no funciona.

¿Alguna idea de dónde me estoy equivocando?

gracias de cualquier manera

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que en su secuencia de comandos, ¿qué tal modificar this a this.value o this.id ? Parece que en este caso, this no se puede analizar. Entonces, cuando se modifica su secuencia de comandos, ¿qué tal la siguiente modificación?

Guión modificado:

En esta modificación, se modifica su HTML.

 <form id="viewOptionsForm"> <fieldset class="viewOptionsFieldset"> <input type="radio" id="all" name="viewOptionsRadio" value="All" checked="checked" onchange='google.script.run.viewOptionsFormRadioChange(this.value);' > <label for="all">All</label><br> <input type="radio" id="firstImport" name="viewOptionsRadio" value="First Import" onchange='google.script.run.viewOptionsFormRadioChange(this.value);'> <label for="firstImport">First Import</label><br> <input type="radio" id="secondImport" name="viewOptionsRadio" value="Second Import" onchange='google.script.run.viewOptionsFormRadioChange(this.value);'> <label for="secondImport">Second Import</label><br> <input type="radio" id="compositionLinking" name="viewOptionsRadio" value="Composition Linking" onchange='google.script.run.viewOptionsFormRadioChange(this.value);'> <label for="compositionLinking">Composition Linking</label><br> <input type="radio" id="underTheHood" name="viewOptionsRadio" value="Under the Hood" onchange='google.script.run.viewOptionsFormRadioChange(this.value);'> <label for="underTheHood">Under the Hood</label> </fieldset> </form>

Pero, en este caso, el valor devuelto es el valor de cadena como First Import , Second Import ,,,. Por lo tanto, es posible que deba modificar su Google Apps Script de la siguiente manera.

 function viewOptionsFormRadioChange(checkbox) { if(checkbox == "Under the Hood") { SpreadsheetApp.getActive().toast("underTheHood Selected", "Title", 15); } }

Con esta modificación, cuando marca "Bajo el capó", se ejecuta la toast() .

Nota:

  • Si desea utilizar el valor de id , modifique this.value a this.id . Por esto, puede usar el valor de ID en su etiqueta HTML. Es como if(checkbox == "underTheHood") {,,,} en lugar de if(checkbox == "Under the Hood") {,,,} .
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!