Answer the question
In order to leave comments, you need to log in
Why doesn't the JS code inside the form work?
I need to change the text in the contact form from the Contact Form 7 plugin, depending on the language, to the desired language.
This is how the JS turned out:
var getLangCode = 'lv'; // Упрощенный вид кода
if(getLangCode == "lv")
{
document.getElementById('cf7-form-text').value='Jūsu vārds';
document.getElementById('cf7-form-telefon').value='Jūsu tālrunis';
}
Answer the question
In order to leave comments, you need to log in
The reasons may be different...
1) Exclude the presence of any js errors in the browser console related or not related to this code.
2) See if the getLangCode variable is set to the correct value. How exactly on the client do you get the value of the language variable? You can also change the text on the server side. Do you have a wpml plugin? And here's how to check the current language
<?php if ( ICL_LANGUAGE_CODE=='lv' ) : ?>
//code
<?php endif; ?>
document.addEventListener("DOMContentLoaded", function() {
// код
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question