parseInt(numstring, [radix])
The parseInt method syntax has these parts: Part Description
numstring Required. A string to convert into a number.
radix Optional. A value between 2 and 36 indicating the base of the number contained in numstring. If not supplied, strings with a prefix of '0x' are considered hexidecimal and strings with a prefix of '0' are considered octal. All other strings are considered decimal. 把字符串转换成数字,要习惯去查msdn或者chm文件document.form1.txt3.value=parseInt(document.form1.txt1.value)+parseInt(document.form1.txt2.value);
The parseInt method syntax has these parts: Part Description
numstring Required. A string to convert into a number.
radix Optional. A value between 2 and 36 indicating the base of the number contained in numstring. If not supplied, strings with a prefix of '0x' are considered hexidecimal and strings with a prefix of '0' are considered octal. All other strings are considered decimal. 把字符串转换成数字,要习惯去查msdn或者chm文件document.form1.txt3.value=parseInt(document.form1.txt1.value)+parseInt(document.form1.txt2.value);
解决方案 »
- $.fn,$.extend,$.fn.extend有什么区别?
- 奇怪的正则表达式
- 请问直接引用google的jquery和google.load有什么区别
- 基于web服务的在.net和java平台上的互操作性
- 请教我想直接用xml做个留言本直接在静态空间执行可行吗
- javascript二维数组怎样排序?
- 文本框的问题
- 问个hta的问题,再问个showModelessDialog的问题
- 帮忙看看啦~
- 请问如何window.close的同时避免弹出是否关闭的对话框(不升级到ie6)
- innerHTML里面的事件为什么有问题啊!!!!!!帮忙
- 如何让弹出窗口不被Googlebar、Alexabar、3721等窗口拦截工具拦截掉?
{
var a = document.form1.txt1.value;
var b = document.form1.txt2.value;
if (a.length>0 && b.length>0)
{
document.form1.txt3.value = parseFloat(a) + parseFloat(b);
}
}
var b = "2" ;
var a2 = eval( a ) ;
var b2 = eval( b ) ;
alert( a2 + b2 )
直接用value表示的是字符串吧。
用parseInt(value)就好了。