电子邮件div文本内容使用PHP邮件功能



我希望能够使用php邮件功能在我的网页上发送电子邮件内容。然而,我遇到了一些问题。我遵循这个电子邮件Div内容问题,已经发布作为一个指南,但它似乎不适合我。我做错什么了吗?

这是我的HTML的一部分:

<form id="myform" method="POST" action="">
<input name="my_hidden_field" id="my_hidden_field" type="hidden" value=""></input>
<div name="priceestimates" id="priceestimates">
<p>The contents of this webpage are not permanent and can change.</p>
</div>
</form>

这是我的jquery,我试图从div输入文本到隐藏的输入:

$("#correctinfo").click(function() {
    $("#my_hidden_field").val($("#priceestimates").text());
});

这是我的PHP,我在这里获得输入的值并将其发送到方框中(我省略了大部分PHP邮件函数,因为我不想用代码淹没我的问题):

$my_hidden_field = $_POST['my_hidden_field'];
$body = $my_hidden_field;

尝试使用表单提交事件添加以下jquery脚本。

<script type="text/javascript">
$(document).ready(function(){
    $("#myform").submit(function() { //notice submit event
        $("#my_hidden_field").val($("#priceestimates").html()); //notice html function instead of text();
    });
});
</script>

最新更新