简体   繁体   English

将数据添加到确认对话框

[英]adding data to a confirmation dialog

I have this dialog function in which it asks "add(the inputted amoun)?" 我有一个对话框功能,其中要求“添加(输入的数字)?”。

In my code i used this ("Add " + amntDATA + " ?") . 在我的代码中,我使用了这个("Add " + amntDATA + " ?") but this is the outcome 但这是结果

Add [object HTMLInputElement] ? 添加[object HTMLInputElement]吗?

html code: html代码:

 Amount: <input type="text" name="contriamnt" id="contriamnt" size="15" placeholder=" Amount"></br></br>
 <button id="searchbutton" type="submit" name="submit" value="Submit">ADD</button></br>

script: 脚本:

 function ConfirmFunction() {
        var amntDATA = document.contribution.contriamnt; 
        if (confirm("Add " + amntDATA + " ?") == true) {
            return true;
        } else {
            return false;
        }
    }

amntDATA is just an input element. amntDATA只是一个输入元素。 You need to get the value of the amntDATA element, get it like: 您需要获取amntDATA元素的 ,如下所示:

function ConfirmFunction() {
        var amntDATA = document.contribution.contriamnt; 
        if (confirm("Add " + amntDATA.value + " ?") == true) {
            return true;
        } else {
            return false;
        }
}

Just use java script property .value 只需使用Java脚本属性.value
eg amntDATA.value; 例如amntDATA.value;

function ConfirmFunction() {
    var amntDATA = document.contribution.contriamnt; 
    if (confirm("Add " + amntDATA.value + " ?") == true) {
       return true;
    } else {
       return false;
    }
}

For further reference or knowledge go through this link . 如需进一步的参考或知识,请通过此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM