Set a value for a next field based on previous selection

Set a value for a next field based on previous selection

BalaKrishnanDhanuskodiBalaKrishnanDhanuskodi Posts: 45Questions: 17Answers: 0
edited September 2018 in Editor

Happy Afternoon,

I am looking at setting up value for the following field 'roomnumber' based on 'Floor' - example if I choose 'Ground' under Floor then the room number should prefix the value of "G00" similarly "F01" for First ... trying to aviod errors in roomnumber feeding.

Explored dependent() doucument with keyevent -change - no luck - if any body could help find answer or intial syntax?.

{
    "label": "Floor:",
    "name": "floor",
    "type": "select",
    "options": [
        "",
        "Ground",
        "First",
        "Second",
        "Third",
        "Fourth",
        "Fifth"
    ]
},
{
    "label": "Room #:",
    "name": "roomnumber"
}

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @BalaTEST ,

    Rather than joining them like that, you could keep them separate but displayed them joined. In the example here, "first_name" and "last_name" are stored separately, and are edited separately, but are displayed in the main table together as a single name. It would be considering whether this approach would work for your floor and room number.

    Cheers,

    Colin

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Colin's suggestion is a good one. Another option if you want to have them as a single field in the database (note that they then wouldn't be editable individually) would be to use a set formatter which would combine the values together.

    Allan

This discussion has been closed.