[Résolu] ajouter un champ prérempli dans un form Zoho form
This support ticket is created Il y a 1 année et 5 mois. 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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
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 = 'lien caché';
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é : lien caché field='courte-description-bien'][/types] mais ceci ne fonctionne pas.
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: 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.
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 = ' lien caché 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>
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: 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 (lien caché).
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 lien caché).