Dependent drop down fields in CustomerTicketMessage.dtl

Moderator: crythias

Locked
leo5nidas
Znuny newbie
Posts: 40
Joined: 16 Apr 2012, 02:00
Znuny Version: 3.2.2
Real Name: Fernando Naranjo
Company: Universidad de Zaragoza

Dependent drop down fields in CustomerTicketMessage.dtl

Post by leo5nidas »

Hi all

We have to put two drop down dynamic fields in the New Ticket Form for the customers, being the different options of one of them dependent of the option selected on the other. We have edited the CustomerTicketMassage.dtl file in order to achieve it. This is the code we have introduced in the final script section:

<!-- dtl:js_on_document_complete -->
<script type="text/javascript">
Core.Customer.InitFocus();

document.getElementById('DynamicField_Field1').onchange=function() {

while (document.getElementById('DynamicField_Field2').options.length) document.getElementById('DynamicField_Field2').options[0]= null;

switch (document.getElementById('DynamicField_Field1').value ) {
case "1":
document.getElementById('DynamicField_Field2').options[0]=new Option("-","");
document.getElementById('DynamicField_Field2').options[1]=new Option("Hello1","1010");
document.getElementById('DynamicField_Field2').options[2]=new Option("Hello2","1012");

break;
case "2":
document.getElementById('DynamicField_Field2').options[0]=new Option("-","");
document.getElementById('DynamicField_Field2').options[1]=new Option("Hello3","1112");
document.getElementById('DynamicField_Field2').options[2]=new Option("Hello4","1201");
break;

}
}
</script>
<!-- dtl:js_on_document_complete -->

Sadly, this is not working, and we don't know why. We have checked the code and it seems correct.

More strange: There is another javascript function in the same section that makes visible/not visible several dynamic fields depending on the queue selected in the ticket form and it works well.

Please, could you tell us how to make it work?

Thank you in advance and regards.
OTRS 3.2.2 (production/testing) on Debian 5.04 Lenny with MySQL database
leo5nidas
Znuny newbie
Posts: 40
Joined: 16 Apr 2012, 02:00
Znuny Version: 3.2.2
Real Name: Fernando Naranjo
Company: Universidad de Zaragoza

Re: Dependent drop down fields in CustomerTicketMessage.dtl

Post by leo5nidas »

Please. Could anybody help us? This is important for us, because the secondary drop down list has a lot of values if it is not filtered by the first drop down.

Thank you
OTRS 3.2.2 (production/testing) on Debian 5.04 Lenny with MySQL database
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Dependent drop down fields in CustomerTicketMessage.dtl

Post by jojo »

use ACLs
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
Locked