<input type="text" id="sid" /> 
<input type="text" id="sname" /> <a id="1" onclick="check(this)">名字1 </a> 
<a id="2" onclick="check(this)">名字2 </a> 
<a id="3" onclick="check(this)">名字3 </a> 
<a id="4" onclick="check(this)">名字4 </a> 
<a id="30" onclick="check(this)">名字30</a> 
<SCRIPT LANGUAGE="JavaScript">
<!--
function check(obj){
document.getElementById("sid").value = obj.id;
document.getElementById("sname").value = obj.innerHTML;
}
//-->
</SCRIPT>

解决方案 »

  1.   


    <script>
    function get(obj) { 
    document.getElementById("id").value=obj.id;
    document.getElementById("name").value=obj.innerText;
    }
    </script><input type="text" id="id" /> 
    <input type="text" id="name" /> <a id="1" href="#" onclick="get(this);">name1 </a> 
    <a id="2" href="#" onclick="get(this);">name2 </a> 
    <a id="3" href="#" onclick="get(this);">name3 </a> 
    <a id="4" href="#" onclick="get(this);">name4 </a>