Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!