How do I populate a hidden field with a specific value based on a users selection

  • MyPartySupplies
    Asked on October 20, 2016 at 1:55 PM

    Hi

     

    Let's say I have a list of cities:

    London

    Birmingham

    Liverpool

    Berlin

    Frankfurt

    and I would like to assign a 'region' to each of them and then populate a hidden field with a unique value based on the users selection.

    So I have 2 regions

    UK (1)

    Germany (2)

     

    Now whenever a user selects London, Birmingham or Liverpool I would like to populate a hidden "region" field with either "UK" or a numerical value (1)

    While if the user selects Berlin or Frankfurt I would like to populate the hidden "region" field with either "Germay" or a numerical value (2).

     

    Essentially this consists of two tables with N entries where values in table 1 (Cities) match a corresponding value in table 2 (Regions)

    How can I achieve this with Jotform?

     

    Thanks in advance

  • Kiran Support Team Lead
    Replied on October 20, 2016 at 4:33 PM

    You may populate the hidden field with a value based on the selection of another field using a set of conditions

    Please see the conditions set on the demo form with the list of cities in a dropdown and the region is a text box field.

    How do I populate a hidden field with a specific value based on a users selection Image 1 Screenshot 30

    You may hide the Region field on the form by selecting the Hide Field option from the field properties.

    How do I populate a hidden field with a specific value based on a users selection Image 2 Screenshot 41

    Please see the demo form below and feel free to clone it to your account.

    https://form.jotform.com/62936072581965

    Hope this information helps! 

     

  • MyPartySupplies
    Replied on October 21, 2016 at 6:44 AM
    Thanks Kiran
    That works - but it could be very tedious if I have dozens (or hundreds) of
    cities and regions. Is there any way I can populate this in a more
    database-table like structure and then do a lookup from one to the other
    based on the value?
    i.e.
    *Cities*
    *Region_ID | Name*
    1 | London
    1 | Birmingham
    1| Newcastel
    2| Berlin
    2| Frankfurt
    etc
    and a Regions table like
    *Regions*
    *Region_ID | Region_Name*
    1 | UK
    2 | Germany
    3 | France
    4 | other
    etc
    and then do a lookup (where London for example would return a Region_ID of
    1 which is mapped in the Regions table to "UK") - rather than a VERY long
    conditions statement?
    Please let me know - thanks in advance.
    Dieter
    ...
  • Nik_C
    Replied on October 21, 2016 at 7:28 AM

    Unfortunately, I don't see a way to that on a form itself. There is Matrix field for example, that you can use for a table, but, you can not use conditions to copy a value to it's fields, since you can not specify which data will go to certain field.

    I'm thinking that best way for you to manage that is to integrate your form with Spreadsheets and manage your data there:

    How do I populate a hidden field with a specific value based on a users selection Image 1 Screenshot 20

    You will be able to search, review and to all necessary checkings right there.

    Could something like that work for you?

    Please let us know.

    Thank you!