Skip Navigation

[Resolved] ajouter un champ prérempli dans un form Zoho form

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.

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 1 year, 4 months ago.

Author
Posts
#2619633
Capture d’écran 2023-06-28 à 15.28.59.png

Bonjour,

J'ai besoin d'aide pour ajouter un champ pré rempli dans un formulaire Zoho form qui est en java script.
Voici le code dont je dispose.

J'ai besoin d'ajouter dans l'url "f.src = 'hidden link';
Je dois ajouter mon champ : [types field='courte-description-bien'][/types] à la fin de l'url pour pouvoir mettre en place un champ caché pour l'utilisateur et affichera les valeurs pré-remplies dans mon interface.
J'ai essayé : hidden link field='courte-description-bien'][/types] mais ceci ne fonctionne pas.

Pouvez-vous m'aider ?
Merci d'avance

#2619903

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Bonjour

Sorry, we can't offer support in French.

We also can't provide support for custom code, though I'll see if I can offer some guidance.

From what you shared above, it looks like you are trying to output a shortcode (the types shortcode) in the context of a JavaScript file, where it will not work.

Shortcodes are evaluated on the server (not in the browser) at the time the page is built, when the page content is parsed by WordPress.

So you can include a shortcode in the content of a post or page, or in a template you make with Toolset, or the output of a View made with Toolset, or a Form rendered by Toolset, and it will be evaluated and in the case of the types shortcode replaced with the field value it refers to.

The only way to "mix" JavaScript and shortcodes is if you add the JavaScript via the post content (if you are using the block editor in a Custom HTML block, for example), so you could do something like this:

<script type="text/javascript">
    const fieldValue = "[types field='my-field'][/types]";
    alert( "My field's value is " + fieldValue);
</script>

I don't know the context where you are using your JavaScript above, but you will likely need a solution based on something like I shared.

If that's not something you know how to do, you may need to find a developer to do that for you.

#2620025
Capture d’écran 2023-06-29 à 20.25.35.png
Capture d’écran 2023-06-29 à 20.25.21.png

Bonjour, merci pour votre réponse, je n'ai pas réussi à faire fonctionner. Peut-être avez-vous une solution avec des infos plus complètes ? Voici en pièces jointes le code à modifier et le résultat attendu. Voici ci-dessous le code que je dois intégrer dans ma zone html :
<div id="zf_div_ 00wgLXUwnDnj2PujmlkgehtyC_- TReEuGnWSypXACg0"></div>< script type="text/javascript">( fonction() {
essayer{
var f = document.createElement(" iframe");
f.src = ' hidden link lesdrlesdedamesdepaname/form/ Jeveuxunrdv/formperma/ 00wgLXUwnDnj2PujmlkgehtyC_- TReEuGnWSypXACg0?zf_rszfm=1 ';
f.style.border="aucun" ;
f.style.height="442px" ;
f.style.width="90%" ;
f.style.transition="all 0.5s easy" ;

var d = document.getElementById("zf_div_00wgLXUwnDnj2PujmlkgehtyC_-TReEuGnWSypXACg0");
d.appendChild(f);
window.addEventListener(' message', fonction (){
var evntData = événement.données ;
if( evntData && evntData.constructor == String ){
var zf_ifrm_data = evntData.split("|");
si ( zf_ifrm_data.length == 2 ) {
var zf_perma = zf_ifrm_data[0] ;
var zf_ifrm_ht_nw = ( parseInt(zf_ifrm_data[1], 10) + 15 ) + "px" ;
var iframe = document.getElementById("zf_ div_00wgLXUwnDnj2PujmlkgehtyC_ -TReEuGnWSypXACg0"). getElementsByTagName("iframe") [0] ;
if ( (iframe.src).indexOf(' formperma') > 0 && (iframe.src).indexOf(zf_perma) > 0 ) {
var prevIframeHeight = iframe.style.height ;
if ( prevIframeHeight != zf_ifrm_ht_nw ) {
iframe.style.height = zf_ifrm_ht_nw ;
}
}
}
}
}, FAUX);
}attraper(e){}
})();</script>

Je vous remercie encore de votre aide.

#2620201

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

From your screenshots it looks like you are appending the string from the form submission to the URL, but the string can include spaces (and possibly other problematic characters) that cannot be included in a URL.

So the string needs to be URL encoded.

You could either write a custom shortcode to use in place of the types shortcode that gets the field value and passes it through urlencode() before returning it (hidden link).

Or you could do something similar within JavaScript, so you assign the value from the types shortcode to a variable, and then pass the variable through encodeURI() before appending it to the URL (see hidden link).