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.
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