Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

131
Visualizações
Dropdown selected option in email

I'm trying to get the value selected by the user in my dropdown form to be send with my email.

The values are generated with this code :

function wpb_hook_javascript() {
?>
<script type="text/javascript">
    var myDiv = document.getElementById("myDiv");
    var selectList = document.createElement("select");
    selectList.id = "mySelect";
    myDiv.appendChild(selectList);
    var activite = document.querySelectorAll(".info-box-content h3");
    console.log (activite);
    for (var i = 0; i < activite.length; i++) {
        var array = activite[i].innerText;
        console.log (array);
        var option = document.createElement("option");
        option.value = array;
        option.text = array;
        selectList.appendChild(option);
    }
    console.log ("retour var array : " + array);


</script>
<?php
}
add_action('wpforms_wp_footer', 'wpb_hook_javascript');

With it I get the different values on my page in the class info-box-content as h3 and make them options values for my dropdown inserted in the myDiv DIV in my form.

With the code below I want to add the HTML block with the myDiv DIV in my notification email :

function wpf_dev_email_display_other_fields( $fields ) {
    return array( 'divider', 'pagebreak', 'html' );
}
     
add_filter( 'wpforms_email_display_other_fields', 'wpf_dev_email_display_other_fields', 10, 1 );

Everything works fine except that the value selected by the user is not in the email content.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Sorry for misusing the answer space because I don't have much reputation. So my baby..wpb_hook_javascript() is not returning any value it's just executing the JS script. So Either you have to return something in wpb_hook_javascript() func or store the values in the PHP variable. Also, your question is not clear, what are these:- wpforms_email_display_other_fields,wpf_dev_email_display_other_fields,add_filter and add_action

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda