我正在尝试处理其中一个页面中的按钮,但使用 formaction 方法/属性时我的语法困惑了。我希望 Servlet 路由中的“senddate”参数基于文本框中的值。我检查文本框并得到一个值。我什至尝试对 mousedown 函数执行一些警报,以确保 $('#txtProcessedDate').val() 有效并获取日期。但它在 servlet 中不起作用,因为它显示“$(”。在此 formaction 语句中使用 txtProcessedDate 文本框值的最佳方法是什么?
<button style="margin-left:20%; font-weight:bold" id="updatePayment"
type="submit"
formaction="EFTscreen?action=routeEFTC&senddate=$('#txtProcessedDate').val() "
class="btn btn-success bold">Update Payment Status
</button>
感谢您的帮助
最佳答案
您所拥有的不是将值连接到属性值文本的正确方法。你可以这样做:
$("#updatePayment").attr({"formaction": $("#updatePayment").attr("formaction")+"&senddate="+$("#txtProcessedDate").val ()});
关于javascript - 使用文本框中的值到按钮形成操作上的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37275954/