Dynamic Fields Canton and Distrito are dependent, and load perfectly when I select or change each other. I used this code:
Code: Select all
#PROVINCIA
<script type="text/javascript">//<![CDATA[
$('#DynamicField_Provincia').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID', [ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', , 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID', 'DynamicField_Provincia', 'DynamicField_Canton', 'DynamicField_Distrito']);
switch ( $('#DynamicField_Provincia :selected').text() ) {
case "San Jose":
var request = $.ajax({
type: 'GET',
url: 'cantones.pl?q=' + 'San Jose',
dataType: 'html'
});
request.done( function(data){
$('#DynamicField_Distrito').empty();
$('#DynamicField_Canton').empty();
$('#DynamicField_Canton').append(data);
});
break;
case "Alajuela":
var request = $.ajax({
type: 'GET',
url: 'cantones.pl?q=' + 'Alajuela',
dataType: 'html'
});
request.done( function(data){
$('#DynamicField_Distrito').empty();
$('#DynamicField_Canton').empty();
$('#DynamicField_Canton').append(data);
});
break;
.
.
.
#CANTON
<script type="text/javascript">//<![CDATA[
$('#DynamicField_Canton').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID', [ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', , 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID', 'DynamicField_Provincia', 'DynamicField_Canton', 'DynamicField_Distrito']);
var canton = $('#DynamicField_Canton :selected').text();
$("#DynamicField_Canton").val($('#DynamicField_Canton :selected').val());
var request = $.ajax({
type: 'GET',
url: 'distritos.pl?q=' + canton,
dataType: 'html'
});
request.done( function(data){
$('#DynamicField_Distrito').empty();
$('#DynamicField_Distrito').append(data);
});
});
//]]></script>
#DISTRITO
<script type="text/javascript">//<![CDATA[
$('#DynamicField_Distrito').bind('change', function (Event) {
Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'PriorityID', [ 'TypeID', 'Dest', 'NewUserID','NewResponsibleID', 'NextStateID', 'ServiceID', , 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID', 'DynamicField_Provincia', 'DynamicField_Canton', 'DynamicField_Distrito']);
$("#DynamicField_Distrito").val($('#DynamicField_Distrito :selected').val());
});
//]]></script>
But not the same situation when I change Canton or Provincia, doesn't add the selected attribute.
I guess for this reason, when I submit the ticket, I get an error that say "The field content is invalid" and change the 2 dependent fields in color red, empty.
Someone has faced with this issue or knows a fix. I really appreciate help, I have days trying to resolve the problem.