My goal is: Select categories and taxonomy based on url parameters in a form
https://toolset.com/forums/topic/get-url-parameter-for-cred-form-taxonomy-and-select-it/
If found this thread and managed to use the first jscript to select a category in my add a new post form. So this works.
But I have a conditional in a select field (Kerntaken= taxonomy) based on the selected category to display a specific taxonomy
So the category "Opdrachten" is selected based on url parameter /?categorie=Opdrachten. But based on this selection a second url parameter ?kerntaak= should make a selection for the taxonomy selection field, for example ?kerntaak=training which should select the taxonomy "Geven van trainingen".
The jscript I use for the caregory:
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
var param = getUrlParameter('categorie');
jQuery('select[name="category[]"]').find("option:contains('" + param + "')").attr('selected', 'selected');
I copied this script and adjusted the variables (this works) but then I get errors when saving the form: wrong combination of variables use.