在已经创建的Google表单上找到元素的ID? [英] Find id of element on already made google form?

查看:115
本文介绍了在已经创建的Google表单上找到元素的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google文档上创建了一个表单,并且我有一个我刚刚创建的脚本(不完整),它将分析表单上的响应,并根据来自其他Google文档的信息验证它们。通过试验和错误,我已经找出了表单上所有元素的id。我用过:

  var body =
var bodyTitle =


for(var i = 1; i {
body = body ++ its [i] .getId()
bodyTitle = bodyTitle ++它的[i] .getTitle()
}

然后通过记录,基本上只是计数,第5编号匹配第5个标题,我有所有的编号。我只是想知道下一次,有没有一种方法可以查看表单,并发现它没有这样做的ID?



使用HTML表单(我使用chrome fyi)你可以右键单击,检查元素,并且可以看到页面元素的id,并在javascript中通过该id引用它们。有没有办法在Google表单中执行此操作?这样我就不必拧出所有的ID和标题并将它们匹配起来。

请注意:这些都是用户在Google表单中创建的所有表单,他们坚持要制作这些表单。这些都不是代码,所以我一直没有能够编码我自己。

解决方案

类似这样的东西会告诉你记录器中的ID ...

  var form = FormApp.getActiveForm(); 
var items = form.getItems();
for(var i in items){
Logger.log(items [i] .getTitle()+':'+ items [i] .getId());
}

要在Chrome >> View Form中右键查看ID在问题标签 >>检查元素>>查找 for =entry_XXXXXXX属性。那'xxxxxxx'将是id。


I have a form made on google docs, and I have a script that I've just created (that isn't complete) that will analyze the responses on the form, and validate them based on info from a different google doc. Through trial and error I have figured out the id's for all of the elements on said form. I used:

var body = ""
var bodyTitle = ""


for (var i = 1; i < its.length; i ++)
{
    body = body + "  " +its[i].getId()
    bodyTitle = bodyTitle + "   " + its[i].getTitle()
}

and then by logging that out and basically just counting, the 5th id matches the 5th title, I have all of the id's. I'm just wondering for next time, is there a way I can look at the form and find it'd ID without doing this?

With HTML forms (I use chrome fyi) you can right click, inspect element, and you can see the id for page elements, and refer to them by that id in javascript. Is there a way to do this in Google Forms? that way I don't have to screw with just logging out all the id's and titles and matching them up.

Keep in mind: these are all forms created in Google Forms by users, they insist on making them. None of them are code made so I haven't been able to code the id's myself.

解决方案

Something like this will show you the ids in the logger...

var form = FormApp.getActiveForm();
var items = form.getItems();
for (var i in items) { 
  Logger.log(items[i].getTitle() + ': ' + items[i].getId());
}

To see the IDs manually in Chrome >> View Form >> right-click on the question Label >> Inspect element >> look for the for="entry_XXXXXXX" attribute. That 'xxxxxxx' will be the id.

这篇关于在已经创建的Google表单上找到元素的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆