日期:2014-05-16  浏览次数:20381 次

求教,如何实现这种效果?
请教,如何实现网易邮箱添加联系人的这种效果?

点击一次“添加即时通讯ID”,就出现一条新记录

再点击一次,就再出现一条,可以无限循环下去


------解决方案--------------------
HTML code


<html>
<head>
<SCRIPT LANGUAGE="JavaScript">

function addRow() 
{  
    var root = document.getElementById("tbody"); 
    var allRows = root.getElementsByTagName('tr'); 
    var cRow = allRows[0].cloneNode(true) 
    root.appendChild(cRow); 
     
}  
function removeRow(r) 
{ 
    var root = r.parentNode; 
    var allRows = root.getElementsByTagName('tr') 
    if(allRows.length>  1) 
        {root.removeChild(r);} 
    else 
        alert("only one row left, you can not remove it!"); 
}

</SCRIPT>
</head>
<body >

<table>
<tbody id="tbody"> 
<tr>     
 <td>
<select name="s1">
<option>请</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<input name="s2">  
<input type="button" value="Remove" onclick="removeRow(this.parentNode.parentNode)">  
</td></tr>
 </tbody>
<tr>
<td>
<input name="button" type="button" value="Add row" onclick="addRow()"> 
</td> 
</tr> 
</table> 
</body>
</html>

------解决方案--------------------
[code=VBScript] <head><script language="JavaScript"> 
function addFile() 

var str = '<br/><select name="select"></select><input type="text" name="textfield" />' 
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str) 

</script>
</head>

<body>
<p id="MyFile"><select name="select">
</select>
<input type="text" name="textfield" /></p>
<input type="button" value="增加文件" onclick="addFile()"/>
</body>code]