dongzhucha3999 2019-03-17 21:04
浏览 61
已采纳

引用具有与之关联的类的id(phpmailer)

I'm trying to get a value from my html file for my phpmailer email but keep getting an unidentified index error.

the html for it is:

<label for="signature"></label>
<input type="text" placeholder="Signature:" name="signature" id ="signature" class="amatic">


<button type="button"  id = "info" onclick="changeFont()">Confirm Signature</button>

The js associated with it is:

<script>
function changeFont() {
  var fon = document.getElementById("signature");
  if (fon.className == "amatic") {
    fon.className = 'roman';
  } else {
    fon.className = 'amatic';
  }
}
</script>

<script type="text/javascript">
    $(function(){
        $('#info').click(function() {
            $(this).hide();
            signature.disabled = true;

        });

    });
</script>

So basically, when the user confirms their signature the font will change to a signature style and they can no longer edit that field.

When I try to call the value in Php for the email body by doing:

Signature: {$_POST['signature']}

I get the unidentified index error. Now it works when I get rid of the class, so my question how do I get the value for my email with the class associated with it?

I tried {$_POST['signature.roman']} but get an error with that as well. I've tried researching it but can't seem to find anything

Hope that makes sense, thanks in advance

Edit: The html is part of a form as so:

When they finish the form and hit submit at the bottom of that page application.php runs.

The rest of the email sends which is why I'm confused as to why I get the error with the signature id, unless I'm missing something completely obvious?

Edit: php code now deleted

  • 写回答

1条回答 默认 最新

  • doukaojie8573 2019-03-17 21:16
    关注

    Keep in your mind, Fields that's have disabled attribute are not submitted and their values are not posted.

    to solve your problem use readonly attribute instead :

    $(function(){
        $('#info').click(function() {
            $(this).hide();
            //signature element
            $("#signature").attr({readonly : true});
    
        });
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误