Hidden field in a Google Form

后端 未结 5 1071
面向向阳花
面向向阳花 2020-11-30 02:52

I am adding a unique ID to each submission of the form. Right now, I made that ID the first field, and pre-filled it with the ID, along with a help text asking the user not

相关标签:
5条回答
  • 2020-11-30 03:29

    I assume you're only interested in ways to programmatically assign a unique ID before the user fills out your form.

    No, Google Forms still has no direct support for hidden fields such as you have in HTML Forms. Your only option appears to be the custom styling route, which you're already aware of.

    Here are two promising ideas that just don't work...

    1. Pre-fill a deleted question. If you delete a question from a form, it remains in the response spread sheet - unfortunately Forms suppresses values for deleted questions that are presented in pre-filled URLs, otherwise you'd be able to trick your Unique ID into the submission that way. (I thought this might be a clever work-around, but was disappointed that it didn't work.)

    2. Pre-fill a question on a skipped page1. You can set up a question on a second page that the live form will skip over, and you can also generate a pre-filled URL for that question. So far, so good - but if the user doesn't actually navigate to that page, the pre-filled response is not submitted.


    1Thanks to @AdamL, who posited this idea during a previous discussion on this topic in the old forum.

    0 讨论(0)
  • 2020-11-30 03:33

    The best you can do is to go to settings in the top right corner and click "Collect Email Addresses" this won't collect it but it has a validator and asks the respondent to fill in an email-filtered short answer question.

    Exp IMG 1

    Exp IMG 2

    0 讨论(0)
  • 2020-11-30 03:40

    I’ve bumped into this same problem and there doesn’t seem to be any ready-made solution. Until Google decides to support hidden fields, there’s nothing we can do apart from considering other unusual approaches.

    I’ve come with one of those. It’s an un optimal solution, but it works. Bear with me.

    There is always a hidden key with an unique value in every form. Its own ID.

    If you can map trackable values with form IDs, you’re half way there.

    Here’s my problem and here is what I’ve done.

    I need to share a form to a group of users. All forms need to be identical, and users are allowed to share the form link to other people. I want to track the referrals so a hidden field that could be pre-filled and customized for each first degree user with a unique ID, would FD be optimal. But that doesn't work, so what I've done is:

    • Create a Google Spreadsheet
    • Create a list of referral codes in a sheet
    • Create a form that will work as a template
    • Iterate the referral codes, and for each one, programmatically:
      • make a copy of the template form in Drive and get its form ID
      • create a new sheet in the spreadsheet and get its ID
      • link the just created form with the just created sheet, so the latter serves as store for the former
      • get the form URL and update the referral's sheet with URL, form ID, and Sheet ID.

    In this way, I have as many "instances" of the same form that I share individually to every single user (this can also be done programmatically if you have the emails mapped to the referral codes).

    When any form is submitted, its linked sheet is updated. Using the spreadsheet "on form submit" event, I run an utility in GAS that appends all the values plus identification of the response and form, to a special sheet that serves as summary. This way I just need to look at just one sheet to see all the results from every form, and analyze it.

    Obviously, this is hard to maintain if changes are introduced to the original template form. But, for me, it works as temporary solution.

    Hope it helps.

    0 讨论(0)
  • 2020-11-30 03:46

    You can't do this directly by Google Forms but you can work around:

    1. Create the google form containing the hidden field.
    2. Create a Google Wep App (https://developers.google.com/apps-script/guides/web)
    3. Insert the following code into the default Code.gs file. (This basically opens an index.html template.)

      doGet(e) { return HtmlService.createTemplateFromFile('index').evaluate(); }

    4. Create a new index.html file with the source code of your form.

    5. Make the input field hidden by adding style="display:none" to its enclosing <div>
    6. Insert any template information into the <input value=""> field using <?= your_gscript_code() ?>
    7. Publish the web app (Publish/Deploy web app...) and you're done. Now you have a link to a form which has the desired field hidden and pre-filled with your hidden value.

    With this solution you can apply any custom style and even get rid of other unnecessary html elements while keeping the form hosted by Google.

    0 讨论(0)
  • 2020-11-30 03:48

    I think I've found a solution to your problem. A script on the sheet that your form data is going to can be triggered on form submit. You can then copy and increment a "range" for each row submitted.

    *edit, sample code was requested. In order for this code to work you need to "install a trigger" using the resources menu on your google app script, and use "from spreadsheet" "on form submit". I've boiled what I'm doing down to the following snippet.

    function myFormUpdates(e) {
      var spreadsheet = SpreadsheetApp.getActive()
      //select the sheet you're form is going to post data to
      var sheet = spreadsheet.setActiveSheet(spreadsheet.getSheets()[1])
      //select the last row and a unused column
      var cell = sheet.getRange(sheet.getLastRow(), 3)
      //set data
      cell.setValue('Data')
    }
    
    0 讨论(0)
提交回复
热议问题