控件名 .value
控件名 .value
控件名 [i].checked
.value
for each ob in 控件名 if
ob.checked then
window.alert
ob.value next
控件名 .checked .value
Select 1
Select 3
Select 2
Select 1
Select 2
Select 3
Select
4
Select 1
Select 2
Select 3
Select
4
单行
多行
多选
添加选项
ExpList.add(new
Option("New Option","3"));
删除选项
ExpList.remove(ExpList.selectedIndex);
设置当前选项位置
ExpList.selectedIndex=ExpList.length-1;
循环整个选项 并判断是否被选择
for(i=0;i<ExpList.options.length;i++)
{
if(ExpList.options[i].selected){
//ExpList.options[i].text;
//ExpList.options[i].value;
} }
单个选项的值
ExpList.options[i].text;
ExpList.options[i].value;
<span
id="SomePlace1"></span> <div
id="SomePlace1"></div>
重新设计包含的 html
SomePlace1.innerHTML=" 任意 html 字符串 "
让该空间的内容消失
SomePlace1.style.display="none";
让该空间的内容显示
SomePlace1.style.display="block";
鼠标滑过出现提示
title="Help"
<input type="hidden"
name="MyValueName" value="123">
控件名 .value
跟随事件Event(声明方式特殊)
<div id=hello1
style=position:absolute>太过分了!吃饭不叫我</div> <SCRIPT
for=document
EVENT=onmousemove> document_onmousemove(); function
document_onmousemove() {
hello1.style.left=event.x+10;
hello1.style.top=event.y+10; } </SCRIPT>
<返回>
2.让TextArea自动换行
使用TextArea的Wrap属性
ASP中手动换行用: replace(rs("A"),"</br>", VBCRLF)
str=request.querystring("text1") str=Replace(str, Chr(32), "
") '把空格换成 标志 str=Replace(str, vbCrLf,
"<br>") '把回车换行符换成<br>标志 调出时再转过来就好了
<返回>
3.让TextArea支持Table键 <SCRIPT
LANGUAGE="JavaScript"> <!-- function
testTab() { var sel =
document.selection.createRange(); var mytext=
sel.text; var i,j,k; if (event.shiftKey
&& event.keyCode == 9)
{
arr=mytext.split(String.fromCharCode(13,10))
mytext=""
for(k=0;k<arr.length;k++)
{ for (j=1;
j<=4;j++)
{
if(arr[k].substr(0,1)=="\u0020")
{
arr[k]=arr[k].slice(1)
}
} mytext += arr[k] +
((k==(arr.length-1))? "" :
String.fromCharCode(13,10));
}
with(sel){ sel.text =
mytext;
collapse(true)
moveEnd("character",0)
moveStart("character",(mytext.length ) *
-1)
select()
}
window.event.cancelBubble = true;
event.returnValue =
false; return; }
if (event.keyCode == 9)
{
arr=mytext.split(String.fromCharCode(13,10))
mytext=""
for(j=0;j<arr.length;j++)
{ mytext +=
"\u0020\u0020\u0020\u0020" + arr[j] + ((j==(arr.length-1))? "" :
String.fromCharCode(13,10));
}
with(sel){ sel.text =
mytext;
collapse(true)
moveEnd("character",0)
moveStart("character",(mytext.length -4) *
-1)
select()
}
window.event.cancelBubble = true;
event.returnValue =
false; return;
} } //--> </SCRIPT>
<返回>
4.复制数据到剪贴板
JM_cc(txt)
window.clipboardData.setData("Text",
txt); global.focus(); document.execCommand('Paste'); window.clipboardData.setData("Text", old);
<返回> 5.得到当前选中的文本
var sel =
document.selection.createRange(); var mytext= sel.text;
//当前选中的文本
var e = event.srcElement; //设置文本为选中 var r
=e.createTextRange(); r.moveStart('character',e.value.length); r.collapse(true); r.select();
<返回>
6.客户端脚本的基本对象