下拉菜单如何动态改变网络应用程序?

发布于 2025-01-11 18:46:24 字数 1716 浏览 0 评论 0原文

我正在使用一个 Google App Script Web 应用程序,该应用程序将用于显示学生的微证书。目标是让我可以使用下拉菜单来选择显示哪些类。我通过从 W3Schools 复制来在网络应用程序上创建了下拉列表,但它没有t 实际上起作用。我需要一些帮助才能让下拉菜单完成我今天需要的操作。

在示例屏幕中,您可以看到我设置的视图和包含三个类的下拉列表: Web 应用程序with dropdown

此网络应用程序的数据存储在 Google 表格中,如下所示: 数据

doGet 看起来像这样:

function doGet(e) {
  var htmlOutput = HtmlService.createTemplateFromFile('WebApp');
  var pictures = getPictures(classSelection);
  var names = getNames(classSelection);
  var cutBelts = getCutBelts(classSelection);
  var measureBelts = getMeasureBelts(classSelection);
  var bindBelts = getBindBelts(classSelection);

  var classSize = 10;

  if(pictures.length<10){
    classSize=pictures.length;
  }


  htmlOutput.pictures = pictures;
  htmlOutput.names = names;
  htmlOutput.cutBelts = cutBelts;
  htmlOutput.measureBelts = measureBelts;
  htmlOutput.bindBelts = bindBelts;
  htmlOutput.classSize = classSize;

  return htmlOutput.evaluate();
}

其中变量“classSelection”等于类的名称(101、201 或 202),五个“get”函数(getPictures、getNames)以数组形式返回该类的图片、名称等。

好的,这是我需要帮助的具体问题。

  1. 如何获取下拉列表以将数据(类)发送回 doGet,以便变量“classSelection”更新并仅显示所选类?

同样,对于我用来创建下拉列表的代码(html、css 和脚本),请参阅 此链接,我直接复制粘贴,只更改了下拉标题

I am working with a Google App Script web app that is going to be used to display student micro-credentials. The goal is to make it so I can use a dropdown to choose which classes are displayed. I have created the dropdown on the web app by copying from W3Schools, but it doesn't actually function. I need some help getting the dropdown to do what I need it today.

In the example screen you can see the view I have set up and the dropdown with three classes:
Web app with dropdown

The data for this web app is stored on a Google Sheet, like this:
Data

And the doGet looks like this:

function doGet(e) {
  var htmlOutput = HtmlService.createTemplateFromFile('WebApp');
  var pictures = getPictures(classSelection);
  var names = getNames(classSelection);
  var cutBelts = getCutBelts(classSelection);
  var measureBelts = getMeasureBelts(classSelection);
  var bindBelts = getBindBelts(classSelection);

  var classSize = 10;

  if(pictures.length<10){
    classSize=pictures.length;
  }


  htmlOutput.pictures = pictures;
  htmlOutput.names = names;
  htmlOutput.cutBelts = cutBelts;
  htmlOutput.measureBelts = measureBelts;
  htmlOutput.bindBelts = bindBelts;
  htmlOutput.classSize = classSize;

  return htmlOutput.evaluate();
}

Where the variable "classSelection" is equal to the name of the class (101, 201, or 202) and the five 'get' functions (getPictures, getNames) return the picture, names, etc for that class as an array.

Okay, so here is my specific issue I need help with.

  1. How do I get the dropdown to send data (the class) back to the doGet so that the variable "classSelection" updates and displays only the selected class?

Again, for the code I used to create the dropdown (html, css, and script) see this link, I literally copy-pasted and only changed the drop down titles ????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文