日期:2014-05-16 浏览次数:20485 次
<html>
<head>
<title>文本框的值复制到第二个文本框,第三个左右加字符</title>
</head>
<body>
<form name=form>
<div align="center">输入字符:
<input type=text name=textvalue>
<br>
复制一次:
<input type=text name=mem1 onFocus="if (this.value == ''){this.value=(textvalue.value)}">
<br>
复制两次:
<input type=text name=mem2 onFocus="if (this.value == ''){this.value=('左面' + textvalue.value + '右面')}">
<br>
<input type=reset value="Reset" name="B2">
</div>
</form>
</body>
</html>
<form name=form>
<div align="center">输入字符:
<input type=text name=textvalue onkeyup="fun(this.value)">
<br>
复制一次:
<input type=text name=mem1 id="mem1">
<br>
复制两次:
<input type=text name=mem2 id="mem2">
<br>
<input type=reset value="Reset" name="B2">
</div>
</form>
<script type="text/javascript">
function fun(v){
document.getElementById("mem1").value=v;
document.getElementById("mem2").value="左面"+v+"右面";
}
</script>