在 onclick 函数中将 PUG 中的表单值作为参数传递

pass form value in PUG as a paramater in onclick function

提问人:user6086008 提问时间:11/16/2023 最后编辑:user6086008 更新时间:11/16/2023 访问量:19

问:

我正在尝试从表单中传递一个值,以用作 onclick 按钮中函数中的参数。但我不确定如何获得价值。

此硬编码示例有效:

button.btn.btn-glider(onclick=helpers.subscribe("[email protected]")) Download

我尝试了以下方法从表单中获取值

button.btn.btn-glider(onclick=helpers.subscribe(('fieldEmail').value)) Download

button.btn.btn-glider(onclick=helpers.subscribe(document.getElementById('fieldEmail').value)) Download

mixin Report
    form
        .modal#ReportModal
            .modal-dialog.modal-dialog-centered.modal-dialog-scrollable(role='document')
                        .modal-content
                            .modal-header
                                .modal-title
                        
                                button.close(type="button" data-dismiss="modal") ×
                            .modal-body
                                div.loading.d-none
                                    .spinner#searchSpinner
                                        .bounce1
                                        .bounce2
                                        .bounce3
                                div.form
                                    p.highlight.text-center.small Enter your name and email to download 
                                    div.mb-3
                                        input.form-control(aria-label="Name" id="fieldName" maxlength="200" name="cm-name" placeholder="Name")
                                    div.mb-3
                                        input.form-control.js-cm-email-input.qa-input-email(autocomplete="Email" aria-label="Email" id="fieldEmail" maxlength="200" name="cm-ydkykyi-ydkykyi" required="" type="email" placeholder="Email")
                            .modal-footer

                                button.btn.btn-glider(onclick=helpers.subscribe("[email protected]") Download

这是 IM 调用的函数

function subscribe (email) {

};```
节点.js 巴狗

评论

0赞 Sean 11/16/2023
这似乎不是哈巴狗问题或节点问题,因为它似乎都发生在客户端。如果你问的问题显示编译的 HTML 而不是 Pug,以及显示实际的 JS 函数,你会得到更多的回答。如果您可以删除无关的代码(如微调器)以创建一个最小的可重现示例,这也将改善问题。

答: 暂无答案