获取URL链接到“SECTION”只要 [英] Get URL Link to a "SECTION" only

查看:87
本文介绍了获取URL链接到“SECTION”只要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我是一名招聘经理,我需要在20个不同的日期对20个不同的候选人进行面试,如果他们能够在上述日期出席,我需要是或否确认。我只想在表格中显示分配给受访者的日期,但我需要隐藏在表单中的其他日期(对于其他访调员),以便他们显示在回复表单中。他们觉得特殊也很重要,所以我需要通过预先填充的文本字段中的名称来解决它们(该文本字段将填充在响应表中)。让候选人隐藏起来非常重要,因为他们并不气馁,因此为他们选择一个预先填充的下拉菜单不是一种选择。



理想情况下,这些受访者在打开表单时只会看到2个字段: b
$ b

  • 全名(预填充文本字段)

  • 分配日期(多选:是或否)


< br> 表单(2个表单字段 - 其余隐藏)
<20>被访者(预先填充的文本字段)

  • 20分配的日期(多项选择:是或否)

  • 1 Google回复表(21栏)


    我尝试过...


    1. 预填充的网址链接基于预填充的多选 )

    2. 研究谷歌表格隐藏字段(不幸)

    3. 研究发送自定义链接指向form section(也许?)






    知道实现这一目标的最佳方式吗?



    预先感谢您。




    GOOGLE表格

     ┌───────────── ───────────┐
    │名称(预填)│
    └────────────────────── ───┘

    你将参加< custom-date> ;?

    ⦿是
    ⦾否
    ⦾可能

    ╔════════
    ║提交║
    ╚════════






    GOOGLE SHEET(回覆)

     #| NAME | 1/1 | 1/2 | 1/3 | -   -   -   -   -   - > 1/20 
    ------------------------------------------- --------------
    1 | ARON |是| | |
    ---------------------------------------------- -----------
    2 | BRAD | |是| |
    ---------------------------------------------- -----------
    3 | CRIS | | | NO |
    ---------------------------------------------- -----------
    | | | | |
    | | | | |
    20 | ZEEK | | | |
    VVVVV


    解决方案

    为每位受访者提供唯一的URL参数,并使用应用脚本doGet(e)函数来获取这些参数并提供个性化的网页。 https://developers.google.com/apps-script/guides/web b
    $ b

    简而言之,可以像下面那样创建个性化链接,向webApp发送获取请求
    https://script.google.com/macros/s/...../exec name = A2& date = 1/2/2017
    并获取URL参数:

     函数doGet(e){
    var param = e.queryString //将得到名称= A2&date = 1/2/2017
    //或
    var param = e.parameter / /将获得{name:A2,date:1/2/2017}
    }

    您可以使用简单= CONCATENATE公式来创建个性化链接,如本例所示电子表格。您可以将这些个性化链接发送给每位受访者,当他们访问网页时,您可以通过URL参数为其提供个性化的网页,如下所示:

      function doGet(e){

    var param = e.queryString
    var parameters = param.split(&)
    //这只是检查2如果(参数!= null&& parameter.length == 2){
    param = e.parameter
    var name = param.name $,则存在参数,否则给出无效链接
    b $ b var date = param.date
    var html = HtmlService.createHtmlOutputFromFile(Invite)
    var htmlTemplate = html.asTemplate()。getRawContent()
    //使用replace函数在页面上输入名称和日期
    //您也可以同时替换隐藏的输入值
    htmlTemplate = htmlTemplate.replace(/ customName#/ gi,name)
    htmlTemplate = htmlTemplate.replace(/ customDate#/ gi,date)
    html = HtmlService.createHtmlOutput(htmlTemplate).asTemplate()。eval uate()
    } else {
    var html = HtmlService.createHtmlOutput(< b>无效链接< b>)
    }
    返回html

    }

    Html代码:

     <!DOCTYPE html> 
    < html>
    < head>
    < base target =_ top>
    < / head>
    < body>
    < div id =div_form>> ;
    < form id =RSVPformonSubmit =return false>
    < h1> customName#< / h1>< br>
    < input type =隐藏id =namevalue ='customName#'>
    您将参加customDate#< br>
    < input type =hiddenid =datevalue =' customDate#'>
    < input type =radioname =RSVPvalue =Yeschecked>是< br>
    < input type =radioname =RSVP value =No>否< br>
    < input type =radioname =RSVPvalue =Maybe>也许< br>
    <按钮类型=buttononClick =sendRSVP()>提交< / button>
    < / form>
    < / DIV>
    < div id =accept>< / div>
    < script>

    函数sendRSVP(){
    var resp = []
    resp [0] = document.getElementById(name)。value
    resp [1] = document.getElementById(date)。value
    resp [2] = document.querySelector('input [name =RSVP]:checked')。value;
    google.script.run.withSuccessHandler(closeForm).enterRSVP(resp)
    }

    函数closeForm(foundIndex){
    var subResp
    if( foundIndex){
    subResp =感谢您的回应

    }其他{
    subResp =糟糕!无法找到会议事件
    }

    document.getElementById(div_form)。style.display =none
    document.getElementById(accept)。innerHTML = subResp
    }

    < /脚本>
    < / body>
    < / html>

    最后,这段代码将检查并输入对电子表格中相应行和列的响应

     函数enterRSVP(resp){
    var ss = SpreadsheetApp.openById(id)
    var sheet = ss.getSheetByName (Sheet1)
    var RSVPdata = sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn())。getValues()
    //匹配名称
    for var i = 0; i< RSVPdata.length; i ++){
    if(resp [0] == RSVPdata [i] [0]){
    var setRowIndex = true
    break


    if(setRowIndex)
    var rowIndex = i + 1
    else
    return false
    //匹配日期
    for (var i = 0; i< RSVPdata [0] .length; i ++){
    if(resp [1] == RSVPdata [0] [i]){
    var setColIndex = true
    break bb

    if(setColIndex)
    var colIndex = i + 1
    else
    return false

    sheet .getRange(rowIndex,colIndex).setValue(resp [2])
    返回true
    }

    您可以在电子表格。只需使用Sheet2上的任何链接即可获取个性化表格。一旦你提交这个表单,Sheet1将被更新。



    注意:在上面的例子中,所有的日期格式都是文本/字符串。这是为了防止串联期间的问题。其次,你将不得不编写一个脚本,将上面的链接发送给每位可以轻松实现的受访者。


    Let's say I'm a hiring manager and I need to conduct an interview with 20 different candidates on 20 different dates, and I need a "yes" or "no" confirmation if they can attend on said date. I only want to show the date assigned to the interviewee in the form, but I need the other dates hidden away in the form (for the other interviewers) so they show up in the "Responses" sheet. It's also important that they feel "special", so I need to address them by there name in a pre-populated text field (this text field will be what's populated in the response sheet). It's important to keep the candidates hidden from each other so they aren't discouraged, so making a pre-populated "dropdown" menu for them to choose from isn't an option.

    Ideally, these interviewees would only see 2 fields when opening up the form:

    • There Full Name (pre-populated text field)
    • There Assigned Date (multiple choice: "yes" or "no")


    RECAP:

    • 1 Google Form (2 form fields - the rest hidden)
    • 20 Interviewees (pre-populated text field)
    • 20 Assigned Dates (multiple choice: "yes" or "no")
    • 1 Google "Responses" Sheet (21 columns)

    I've attempted...

    1. Prefilled URL links based on prefilled "multiple choice" answer (no luck)
    2. Research on Google Form "Hidden Fields" (no luck)
    3. Research on sending custom link pointing to "form section" (maybe?)


    Does anyone know the best way for achieving this?

    Thanks in advance.


    GOOGLE FORM

       ┌────────────────────────┐
       │  NAME (pre-populated)  │
       └────────────────────────┘
    
        Will you be attending on <custom-date>?
    
            ⦿ YES
            ⦾ NO
            ⦾ MAYBE
    
       ╔════════╗
       ║ SUBMIT ║
       ╚════════╝
    


    GOOGLE SHEET (Responses)

         #  | NAME    |  1/1  |  1/2  |  1/3  | - - - - - -> 1/20
        ---------------------------------------------------------
         1  | ARON    |  YES  |       |       |
        ---------------------------------------------------------
         2  | BRAD    |       |  YES  |       |
        ---------------------------------------------------------
         3  | CRIS    |       |       |  NO   |
        ---------------------------------------------------------
            |         |       |       |       |
            |         |       |       |       |
         20 | ZEEK    |       |       |       |              
            V         V       V       V       V
    

    解决方案

    You can create personalized links with unique URL parameters for every interviewee and use apps script doGet(e) function to get those parameters and serve personalized web pages. https://developers.google.com/apps-script/guides/web

    In short, personalized link can be created like below to send a get request to the webApp https://script.google.com/macros/s/...../exec?name=A2&date=1/2/2017 and get URL parameters with this:

    function doGet(e){
        var param = e.queryString //Will get name=A2&date=1/2/2017
        //or
        var param = e.parameter  //Will get {"name": "A2", "date": "1/2/2017"}
    }
    

    You can create personalized links using a simple =CONCATENATE formula like in this example spreadsheet in "Sheet2". You can send this personalized links to each interviewee and when they access the web page you serve them personalized web page on the URL parameters like so:

    function doGet(e) {
    
      var param = e.queryString
      var parameters = param.split("&")
      // This just checks only 2 parameters are present else gives a invalid link
      if (param != null && parameters.length == 2){
        param = e.parameter
        var name = param.name
        var date = param.date
      var html = HtmlService.createHtmlOutputFromFile("Invite")
      var htmlTemplate = html.asTemplate().getRawContent()
      // use the replace function to input the name and date on the page 
      // You also replace the hidden input values at the same time
      htmlTemplate = htmlTemplate.replace(/customName#/gi, name )
      htmlTemplate = htmlTemplate.replace(/customDate#/gi, date)
      html = HtmlService.createHtmlOutput(htmlTemplate).asTemplate().evaluate()
      }else {
        var html = HtmlService.createHtmlOutput("<b> Invalid Link <b>")
      }
      return html
    
    }
    

    Html Code:

    <!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
       <div id ="div_form">
        <form id="RSVPform" onSubmit = "return false">
        <h1> customName# </h1> <br>
        <input type = "hidden" id = "name" value = 'customName#' >
        Will you be attending on customDate# <br>
        <input type = "hidden" id = "date" value = 'customDate#' >
        <input type = "radio" name = "RSVP" value = "Yes" checked>Yes <br>
        <input type = "radio" name = "RSVP" value = "No">No <br>
        <input type = "radio" name = "RSVP" value = "Maybe">Maybe <br>
        <button type = "button" onClick ="sendRSVP()">Submit</button>
        </form>
        </div>
        <div id="accept"></div>
        <script>
    
        function sendRSVP(){
        var resp = []
         resp[0] = document.getElementById("name").value
         resp[1] = document.getElementById("date").value
         resp[2] = document.querySelector('input[name="RSVP"]:checked').value;
        google.script.run.withSuccessHandler(closeForm).enterRSVP(resp)
        }
    
        function closeForm(foundIndex){
        var subResp
        if(foundIndex){
          subResp = "Thank You for your response"
    
        } else {
          subResp = "Oops! Cannot find the meeting event"
        }
    
        document.getElementById("div_form").style.display = "none"
        document.getElementById("accept").innerHTML = subResp
        }
    
        </script>
      </body>
    </html>
    

    Finally, this code will check and enter the response to appropriate row and column in the spreadsheet

    function enterRSVP(resp){
     var ss = SpreadsheetApp.openById(id) 
     var sheet = ss.getSheetByName("Sheet1")
     var RSVPdata = sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues()
     //match name
     for (var i=0;i<RSVPdata.length;i++){
       if(resp[0] == RSVPdata[i][0]){
         var setRowIndex = true
         break
       }
     }
      if(setRowIndex)
        var rowIndex = i+1
      else
        return false
      //Match Date
      for (var i= 0; i<RSVPdata[0].length; i++){
        if(resp[1] == RSVPdata[0][i]) {
          var setColIndex = true
          break
        }
      }
       if(setColIndex)
         var colIndex = i+1
       else
         return false
    
       sheet.getRange(rowIndex,colIndex).setValue(resp[2])
       return true
    }
    

    You can find a working example here in this spreadsheet. Just use any links on Sheet2 to get a personalized Form. Once you submit this form Sheet1 will be updated.

    Note: In the above example all the dates are formatted as text/strings. This is to prevent issues during concatenation. Secondly, you will have to write a script to send the above links to each interviewee which is easily doable.

    这篇关于获取URL链接到“SECTION”只要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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