在按钮onclientclick事件的确认框中获取文本框值 [英] getting textbox values in confirm box on button onclientclick event

查看:109
本文介绍了在按钮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

推荐答案

代码中的错误可能因为你添加了一个带字符串的整数。请尝试以下代码:

The error in your code might be because you adding an integer with string. Try following code:
<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事件的确认框中获取文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆