Skip Navigation

[Resolved] How to get the term value topopulate a cred tax single select threw urlparameter

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 21 replies, has 3 voices.

Last updated by Shane 7 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#556658

Hello,
I am trying to pre-populate a cred form taxonomy field which is set on single select.
I have tried

&pays_v=[wpv-post-taxonomy type="pays" format="slug"]

but it seems the url parameter must be the term id, which is the value of the term in the select.
How could I get the term id from my view ?
Thank you.

#556695

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

Thank you for contacting our support forum.

Is it that you want a select value on a form Pre-selected when the user visits the form ?

Will this preselection based on some previously inserted value or will it always one set value.

Please let me know.

Thanks,
Shane

#556712

Is it that you want a select value on a form Pre-selected when the user visits the form ?
Yes, precisely.

Will this preselection based on some previously inserted value or will it always one set value.The value is set in a view showing the post with a button ; the button is set to send a URL parameter to fill the form.

#556720

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

Can I get a link to this page with the URL value being passed?

We may be able to use some Javascript to get this to work for you.

Thanks,
Shane

#556721

Thank you very much for your help.
Could you please activate private fields so I can give you URL and access ?
Thank you.

#557275

Hi, Shane is currently unavailable but will return tomorrow to continue working on this request. Thanks for your patience. I have activated private reply fields here for you.

#557757

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

I'm still a bit confused on what you are trying to achieve. Could you possibly provide some screenshots that could provide more detail because your original posts mentioned pre-filtering the view but this new post mentions some ID. Are these 2 different issues ?

Thanks,
Shane

#557770

Oh I'm sorry, yes, they are 2 different issues... I got mixed up.

Please see this URL : /nouvelle-demande-de-commande/?id_produit=706&id_offre=748&prix_unit_v=250000&qte_v=2&monnaie_v=XOF&incoterm_v=DDP&delai_v=5&pays_v=7

In it, "pays_v=" has value "7", which is a term ID for a taxonomy.

Now I have this CRED form where I need to get this URL parameter to populate the taxonomy field, so I have set a cred field like this

[cred_field field='pays' display='checkbox' urlparam='pays_v' output='bootstrap']

But it seems the "urlparam='pays_v'" attribute doesn't work to populate the cred field...

Thank you.

#557810

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

Its not possible to populate a CRED form element using the URL parameter, you will either need to set the value as a default selected option in Types when the field was created or allow user the select the options.

Thanks,
Shane

#557815

Its not possible to populate a CRED form element using the URL parameter,
This is not true at all ! On that same form you may look at the hidden fields (display:none) where you may see I populate text fields, number fields, select fields, email fields using URL parameter. It works alright. My problem is specific to the taxonomy.

#557844

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

You are absolutely correct. However checkboxes seems to function differently since they require a checked state, however i see no reason why it should not work given that select items are similar in a sense.

Could you provide me with a sample url containing the pays_v value.

Thanks,
Shane

#557846

Yes, please just add "/nouvelle-demande-de-commande/?id_produit=706&id_offre=748&prix_unit_v=250000&qte_v=2&monnaie_v=XOF&incoterm_v=DDP&delai_v=5&pays_v=7" to the domaine name.
Thank you.

#557896

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

I'm not seeing a pays_v value in this urls

/nouvelle-demande-de-commande/?id_produit=706&id_offre=748&prix_unit_v=250000&qte_v=2&monnaie_v=XOF&incoterm_v=DDP&delai_

Thanks,
Shane

#557902

Hello,

Please check again here : /nouvelle-demande-de-commande/?id_produit=706&id_offre=748&prix_unit_v=250000&qte_v=2&monnaie_v=XOF&incoterm_v=DDP&delai_v=5&pays_v=7

Thank you.

#558256

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Roman,

I've checked on this for you and added the following to your form.

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

jQuery( document ).ready(function() {
val = getParameterByName('pays_v')
   jQuery("input[value='" + val + "']").prop('checked', true);
});

This will check the value based on whats in the url.

Thanks,
Shane