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});
    
        });
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度