在按钮onclientclick事件的确认框中获取文本框值

在按钮onclientclick事件的确认框中获取文本框值

本文介绍了在按钮onclientclick事件的确认框中获取文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在onclientclick事件按钮上的确认框中的文本框中输入值如下:

my code to get values entered in textboxes on confirm box on onclientclick event of button is as follows:

<script type="text/javascript">
 function Confirmcall() {
        var call = parseInt (document.getElementById("txtEmpId").value) + document.getElementById("txtEmpName").value + parseInt( document.getElementById("txtSalary").value) + document.getElementById("txtCity").value;
        return confirm(call);
    }
    </script>





但是当我在确认框中单击取消时,会发生输入字符串格式不正确的错误。为什么?此外,我想要在确认框中的值,如empid = 1,empname = abc,sal = 15000,city = xyz.Thanks



but when i click cancel in confirm box error occurs thatt input string is not in correct format . why? Also i want values to apper in confirm box like empid=1,empname=abc,sal=15000,city=xyz.Thanks

推荐答案

<script type="text/javascript">
function Confirmcall() {
var empId = document.getElementById("txtEmpId").value;
var empName = document.getElementById("txtEmpName").value;
var empSalary = document.getElementById("txtSalary").value;
var empCity = document.getElementById("txtCity").value;
var msg = "Emp ID: " + empId + ",Emp Name: " + empName + ",Emp Salary: " + empSalary + ", Emp City: " + empCity;
return confirm(msg);
}
</script>





BTW,你可以在你的问题中使用改善问题你今天早些时候就同样的问题发布了。



BTW, you could have used "improve question" in your question that you posted early today regarding the same problem.


这篇关于在按钮onclientclick事件的确认框中获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 13:41