05-20-2019 06:50 AM
Hello Gents,
i need a script that filter the results of locations by choosing the time zone dropdown form field.
Similar like the link posted above.
For Example:
Time Zone: France, Germany, Spain, Poland.
Locations: Nantes, Paris | Berlin, Hamburg, Stuttgart | Burgos, Cascante, Martorell | Kormoniki, Sroda Slaska
Now i want, that when the time zone value is on Spain that the dropdown form field for location only show Burgos, Cascante and Martorell.
I anybody able to show me, how the script should look like?
Kind regards
Jacob
Solved! Go to Solution.
05-21-2019 08:21 PM
Jason - i adjust your script
and everything works fine for me. Perfect!!! It was a hard job for me.....but finally it's a victory for me. :-)
Result: Time Zone value filter custom field ui_duration_text and copy the outcome to "ui_comany". (normally on hide)
Thanks
Kind regards
Jacob
05-20-2019 09:27 AM
05-20-2019 12:38 PM
Yes - i thought about ist.
But i don't have an idea to implement it.
Jason:
This is your script. It should be easy for you to edit this script for my needs.
Steps:
1. time zones -> on change go to step 2.
2. custom field (dropdown) to set special values for locations.
script:
<script>
(function(){
setTimeout(function(){
//Script for dropdown weekly/quarterly & sms formularfield not required !!
var setup = function(){
if(($("#guestUser\\.fieldValues\\.ui_location").val()) == 'Germany') {
persons = {
'Berlin':'Berlin',
'Munich':'Munich',
}
} else if (($("#guestUser\\.fieldValues\\.ui_location").val()) == 'Spain') {
persons = {
'Burgos':'Burgos',
'Cascante':'Cascante',
}
} else {
persons = {
'Choose department': 'Choose department',
}
}
return persons;
}
setup();
jQuery("input[name='guestUser.fieldValues.ui_company']").parent().hide();
jQuery("input[name='guestUser.fieldValues.ui_duration_text']").parent().hide();
jQuery("input[name='guestUser.fieldValues.ui_duration_text']").parent().after("<div class='ui-select'><div data-corners='true' data-shadow='true' data-iconshadow='true' data-wrapperels='span' data-icon='arrow-d' data-iconpos='right' data-theme='a' class='ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-right ui-btn-up-a' id='outerDiv'><span class='ui-btn-inner'><span class='ui-btn-text'><span id='displayName'></span></span><span class='ui-icon ui-icon-arrow-d ui-icon-shadow'> </span></span><select name='guestUser.fieldValues.ui_duration_text' id='guestUser.fieldValues.ui_duration_text' class='ui-body-a'></select></div></div>");
jQuery.each( persons, function( key, value ) {
jQuery('#guestUser\\.fieldValues\\.ui_duration_text').append("<option value="+value+">"+key+"</option>");
});
jQuery('#guestUser\\.fieldValues\\.ui_duration_text > option:first-child').attr('selected', 'selected');
jQuery('#guestUser\\.fieldValues\\.ui_duration_text').on('change', function(evt){
jQuery("#guestUser\\.fieldValues\\.ui_company").val(jQuery(this).val());
jQuery('#displayName').html(jQuery(this).find('option:selected').text());
});
jQuery('#guestUser\\.fieldValues\\.ui_duration_text').trigger('change');
},250);
})();
</script>
It works so far, but if i choose another ui_location value the dropdown field for ui_duration_text trigger no change.
Maybe you have a solution for this.
aim:
choose time zone ("ui_location") -> on change -> filter and focus the new values on dropdown field "ui_duration_text" (custom field).
"ui_duration_text" copy the new value automatically to "ui_comany". I need this to transfer the value with the "approval request email" to make it visible for the internal customers.
Kind regards
Jacob
05-20-2019 01:18 PM
05-21-2019 08:21 PM
Jason - i adjust your script
and everything works fine for me. Perfect!!! It was a hard job for me.....but finally it's a victory for me. :-)
Result: Time Zone value filter custom field ui_duration_text and copy the outcome to "ui_comany". (normally on hide)
Thanks
Kind regards
Jacob
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide