图例1 htmlbodyscript language="JavaScript" type="text/javascript" function addEvent(eventHandler) { var tags = document.getElementsByTagName('input'); for(var i=0;itags.length;i++) { if(tags[i].getAttribute('url') == 'true') { if(tags[i].
图例1
<html>
<body>
<script language="JavaScript" type="text/javascript">
function addEvent(eventHandler)
{
var tags = document.getElementsByTagName('input');
for(var i=0;i<tags.length;i++)
{
if(tags[i].getAttribute('url') == 'true')
{
if(tags[i].addEventListener)
{
tags[i].addEventListener('keyup',eventHandler,true);
}
else
{
tags[i].attachEvent('onkeyup',eventHandler);
}
}
}
}
function addInput(e)
{
var obj = e.target ? e.target : e.srcElement;
var tags = document.getElementsByTagName('input');
for(var i=0;i<tags.length;i++)
{
if(tags[i].getAttribute('url') == 'true'&&tags[i]!=obj)
{
tags[i].value = obj.value;
}
}
}
window.onload = function()
{
addEvent(addInput);
}
</script>
<p>
<input id="addr_more1" size="35" value="" name="addr_more1" url="true" />
</p>
<p>
<input id="addr_more2" size="35" value="" name="addr_more2" url="true" />
</p>
<p>
<input id="addr_more3" size="35" value="" name="addr_more3" url="true" />
</p>
<p>
<input id="addr_more4" size="35" value="" name="addr_more4" url="true" />
</p>
</body>
</html>
图例2
<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function getNM(id)
{
var name2 = $("#"+id+"").val();
if (name2 != "") {
for(var i=3;i<6;i++)
$("#NM"+i+"").val(name2);
}
}
</script>
</head>
<body>
<input type="text" id="NM1" value="" />
<input type="text" id="NM2" value="" />
<input type="text" id="NM3" value="" onkeyup="getNM(this.id)"/>
<input type="text" id="NM4" value="" onkeyup="getNM(this.id)"/>
<input type="text" id="NM5" value="" onkeyup="getNM(this.id)"/>
</body>
</html>
需要引用 <script type="text/javascript" src="jquery-1.4.4.min.js"></script>
【本文由:高防cdn http://www.558idc.com/gfcdn.html 复制请保留原URL】