WebSite X5Help Center

 
Thomas H.
Thomas H.
User

Populate a form field based on dropdown option  en

Autor: Thomas H.
Visitado 407, Seguidores 1, Compartilhado 0  

Good moring,

I am using the Contact Form Object on my companies intranet page so employees can submit PTO requests. The "Data Submission" is configured to send the form to our HR department and the "Confirmation e-mail" is being sent to the employees supervisior for approval.

I have a dropdown box for the user to select their supervisor. Currently the user has to manually type the supervisors email address and typos often result in the supervisor not receiving the request.

Is there a way to populate the supervisor email address, based on the dropdown result? I would assume javascript could do it but my javascript knowledge is lacking and assistance would be appreciated. 

The form ids are imObjectForm_1_5 and imObjectForm_1_6

Publicado em
3 RESPOSTAS - 1 CORRIGIR
Thomas H.
Thomas H.
User
Autor

I was able to hack my way through it and make it functional. If any javascript professionals want to chime in, please feel free.

<script>
    var e = document.getElementById("imObjectForm_1_5");
    var supervisorName;
    function onChange() {
        supervisorName = e.options[e.selectedIndex].text;
        if(supervisorName === "*******"){
            document.getElementById("imObjectForm_1_6").value = "*******@*******.com";
        } else if(supervisorName === "*******"){
            document.getElementById("imObjectForm_1_6").value = "*******@*******.com";
        } else if(supervisorName === "*******"){
            document.getElementById("imObjectForm_1_6").value = "*******@*******.com";
        } else {
            document.getElementById("imObjectForm_1_6").value = "";
        }
    }
    e.onchange = onChange;
    onChange();
</script>

Ler mais
Publicado em de Thomas H.
Axel  
Axel  
User
Usuário do mês FR

Hello Thomas,

You need to create a form like this.

Go to the page properties.

And copy your code here with your objects names (here it's my object names)

And the email will be automatically populated.

Hope this helps

Axel

Ler mais
Publicado em de Axel  
Thomas H.
Thomas H.
User
Autor

Ah! That is much cleaner than how I did it. I used a HTML code object on the page. Thank you.

Ler mais
Publicado em de Thomas H.