[Resolved] Select options based on another option selected (jquery)

Moderator: crythias

Post Reply
iwill
Znuny newbie
Posts: 65
Joined: 10 Feb 2021, 10:47
Znuny Version: 6.0
Real Name: William Craveiro

[Resolved] Select options based on another option selected (jquery)

Post by iwill »

Hi there,

Im trying to select an option when i choose a specific option from list above. Any help how can achieve that?

Print of frontend
Image

The main idea is, when i choose Field_Support, select option "94" from StardardTemplateID (Text Template field)

Image

My actual try:

Code: Select all

$(document).ready(function () {
    setTimeout(function () {
        const Action = Core.Config.Get("Action");
        const SupportedActions = ["AgentTicketNote"];

        if ($.inArray(Action, SupportedActions) !== -1) {
            if (Action === "AgentTicketNote") {
                $('#DynamicField_QueueNote').on('change', function () {
                    const Option = $(this).val();

                    if (Option === '- Move -')
                        $('#Subject').val('');
                    else if (Option === 'Field_Support')
                        $('#Subject').val('Nota para Field');
                    else if (Option === 'Field_Support')
                        $("#StandardTemplateID").html("<option value='94'>dados_para_field</option>");
                    else if (Option === 'Helpdesk')
                        $('#Subject').val('Nota para Helpdesk');
                    else if (Option === 'Sistemas_Windows')
                        $('#Subject').val('Nota para Sistemas');
                    else if (Option === 'Networking')
                        $('#Subject').val('Nota para Networking');
                });
            }
        }
    })
});
Solved by me.
Last edited by iwill on 03 Jul 2021, 21:52, edited 1 time in total.
iwill
Znuny newbie
Posts: 65
Joined: 10 Feb 2021, 10:47
Znuny Version: 6.0
Real Name: William Craveiro

Re: Select options based on another option selected (jquery)

Post by iwill »

Any help guys?
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: [Resolved] Select options based on another option selected (jquery)

Post by crythias »

Well, yeah, but honestly, this is a user interface nightmare.

On the one side, you could use ACLs to limit dependent fields. (Possible, PossibleNot)

On another, you could "simply" have the values of dependent fields as children of the first field, maybe show as a Tree instead of a full dropdown.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
iwill
Znuny newbie
Posts: 65
Joined: 10 Feb 2021, 10:47
Znuny Version: 6.0
Real Name: William Craveiro

Re: [Resolved] Select options based on another option selected (jquery)

Post by iwill »

crythias wrote: 10 Jul 2021, 19:30 Well, yeah, but honestly, this is a user interface nightmare.

On the one side, you could use ACLs to limit dependent fields. (Possible, PossibleNot)

On another, you could "simply" have the values of dependent fields as children of the first field, maybe show as a Tree instead of a full dropdown.
Im already achieve that with .js
Post Reply