08-12
03
点击超链接 给文本框赋值
作者:Java伴侣 日期:2008-12-03
复制内容到剪贴板 程序代码
<input type=text id=demo>
<a href=# id=m1>文字1</a>
<a href=# id=m2>文字2</a>
<a href=# id=m3>文字3</a>
<a href=# id=m4>文字4</a>
<a href=# id=m5>文字5</a>
<script>
//定义事件
var txt_box=document.getElementById("demo");
var a1=document.getElementById("m1");
a1.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a2=document.getElementById("m2");
a2.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a3=document.getElementById("m3");
a3.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a4=document.getElementById("m4");
a4.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a5=document.getElementById("m5");
a5.onclick=function(){txt_box.value=this.innerHTML;return false;}
</script>
<a href=# id=m1>文字1</a>
<a href=# id=m2>文字2</a>
<a href=# id=m3>文字3</a>
<a href=# id=m4>文字4</a>
<a href=# id=m5>文字5</a>
<script>
//定义事件
var txt_box=document.getElementById("demo");
var a1=document.getElementById("m1");
a1.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a2=document.getElementById("m2");
a2.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a3=document.getElementById("m3");
a3.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a4=document.getElementById("m4");
a4.onclick=function(){txt_box.value=this.innerHTML;return false;}
var a5=document.getElementById("m5");
a5.onclick=function(){txt_box.value=this.innerHTML;return false;}
</script>
评论: 0 | 引用: 0 | 查看次数: 823
发表评论