CRÉER UNE BOITE DE DIALOGUE (INPUTBOX) AVEC CASES À COCHER

Ce script permet d'inclure un ensemble de cases à cocher dans une boite de dialogue. 

La liste des options se trouve dans une zone nommée choix du fichier

La valeur est recueillie par la fonction getInputBoxValue



Il suffit de lancer cette fonction

var choix = SpreadsheetApp.getActiveSpreadsheet().getRange('choix').getValues().flat()

function inputBoxCheck() {
  var page = `<html>
<style>
  body {
    font-family: Roboto, Arial, sans-serif;
    font-size: 1.08rem;
  }
</style>
<body>`
  choix.forEach(c => page += `<input type="radio" name="choix" value="${c}" onchange="retourner(this.value);" />${c}<br>`)
  page += `
</body><script>
window.close = function(){window.setTimeout(function(){google.script.host.close()},100)};
function retourner(valeur) {
  google.script.run.getInputBoxValue(valeur);
  close();
}
</script>
</html>`
  var html = HtmlService.createHtmlOutput(page)
    .setWidth(240).setHeight(40 + 20 * choix.length);
  SpreadsheetApp.getUi().showModalDialog(html"Choisir ...");
}

et poursuivre le script avec

function getInputBoxValue(valeur) {
  Browser.msgBox(valeur)
  // suite du script
}

cette fonction est lancée automatiquement lorsque la valeur est sélectionnée

Commentaires

Posts les plus consultés de ce blog

INSÉRER UN TABLEAU PROVENANT D'UNE FEUILLE DANS UN COURRIEL

METTRE À DISPOSITION DES INFORMATIONS SANS ACCÈS AU FICHIER COMPLET

NAVIGUER AU SEIN D'UN FICHIER À L'AIDE D'UN MENU DÉROULANT