Javascript函数和事件
一、默认函数
JavaScript提供了一些默认的函数
编码函数escape():将非字母、数字字符转换成ASCII码
译码函数unescape():将ASCII码转换成字母、数字字符
求值函数eval()
数值判断函数isNaN():判断一个值是否为非数值类型
整数转换函数parseInt():将不同进制(二、八、十六进制)的数值转换成十进制整数
浮点数转换函数parseFloat():将数值字串转换成浮点数
1、eval()函数
求值函数eval()的格式为:eval(<表达式>)
下面的例子将用eval函数得到一个文本框的值,
然后通过点击按钮弹出一个对话框将其输出。
<script>
function show(obj)
{
var str=eval("document.Form."+obj+".value");
alert(“你输入的姓名是:”+str);
}
</script>
<form name="Form" id="Form">
姓名:
<input name="name" type="text" value="韦小宝">
<input name="button" type="button" value="提交" onClick=show("name")>
</form>
2、isNaN()函数
数值判断函数isNaN()的格式:isNaN(<量>)
下例中isNaN函数将判断变量是否不是数值,并输出判断结果。
<script>
var x=15;
var y="黄雅玲";
document.write("<LI>x不是数值吗?",isNaN(x));
document.write("<LI>y不是数值吗?",isNaN(y));
</script>
3、parseInt()函数
整数转换函数parseInt()的功能是将不同进制(二、八、十六)的数值转换成十进制整数。
格式:parseInt(数值字串[,底数])
下面演示了将一个二进制数和一个十六进制数转换成十进制数。
<script>
document.write("1101<sub>2</sub>=",parseInt("1101",2),"<sub>10</sub><br>");
document.write("BFFF<sub>16</sub>=",parseInt("BFFF",16),"<sub>10</sub><br>");
</script>
4、parseFloat()函数
parseFloat()是浮点数
相关文档:
(一).确认删除用法:
1. BtnDel.Attributes.Add("onclick","return confirm('"+"确认删除?"+"')");
2. linktempDelete.Attributes["onclick"]="javascript:return confirm('"+"确认删除?"+"');";
3. privat ......
添加
<script>
var oDiv = document.createElement("DIV");
oDiv.id = "shop01";
oDiv.style.top = 200;
oDiv.style.left = 200;
oDiv.style.background = '#FFFF00';
oDiv.style.visibility = 'visible';
oDiv.innerHTML="123123"
document.body.appendChild(oDiv ......
JavaScript API
One of the new features we added to the ASP.Net Report Viewer in Visual Studio 2010 is a JavaScript API to allow you to interact with the viewer on client. In reading many of the posts on the report controls forum, we found that many people struggle when implementing a custom ......
var currItem = listbox.options[currIndex];
var prevItem = listbox.options[currIndex - 1];
&n ......