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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?