日期:2014-05-18  浏览次数:20653 次

如何实现这个功能啊
我想用一个文本域接收用户输入的信息,当用户输入信息后,点添加按纽又显示一个文本域.就是类似于上传多个文件那种功能,当用户点添加后又可以看到另一个文本域.

------解决方案--------------------
<script language= "javascript ">
var StraddItem= " ";
var ItemNo=1;
function AddItm()
{
var mybag= "Mybag "+(ItemNo-1);
StraddItem= " <table id=TblItm "+ItemNo+ " WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=1 BORDERCOLOR=red> <TR> <TD COLSPAN=6 > &nbsp </TD> </TR> <tr colspan=6 height=1 align=center> <td align=center colspan=13 width=100% bgcolor=mistyrose> 选中 <INPUT TYPE=CHECKBOX name=chkAppIt "+ ItemNo + " value=Y> &nbsp; "+ " 文件 "+ ItemNo + ": <input type=file name=file "+ ItemNo + " size=50> </td> </tr> <TR> <TD COLSPAN=6 > &nbsp </TD> </TR> </table> <div id=mybag "+ItemNo+ " > </div> ";
document.all(mybag).innerHTML=StraddItem;
ItemNo++;
}
function DelItm()
{
var i;
var bSel;
var strURL;

for(i=1;i <ItemNo;i++)
{
chkAppItx= "chkAppIt "+i;
TblItmx= "TblItm "+i;
if (document.all(chkAppItx).checked==true)
{document.all(TblItmx).style.display= "none ";
bSel=true;
}
}
if (bSel != true) {alert( "请首先选中您要删除的文件行 ") ; return false; }
else return true;
}
</script>
------解决方案--------------------
随便写了个,你试试看
<script>
function moreArea()
{
document.all.Add.insertAdjacentHTML( "BeforeBegin ", " <br> <input type=text name=pic id=Pic> ");
}
</script>
<input type= "text " name= "Pic " id= "Pic ">
<p id= "Add " onClick= "moreArea() "> <input type= 'button ' name= "More " value= '添加 ' > </p>
------解决方案--------------------

<script type= "text/javascript ">
<!--
function Attachment(maxatts){
var attHTML = ' <!--Attachment--> <input type= "hidden " name= "attachprem " value= "0 " /> '
+ ' <table cellspacing= "0 " cellpadding= "0 "> <tbody> ' +
' <tr> <td style= "vertical-align:top; "> </td> '
+
' <td id= "att " style= "font-size:10pt; "> <div id= "ia "> <span class= "l " onclick= "javascript:initattachment(this); "> &nbsp;&nbsp;上传附件 </span> </div> '
+
' <div id= "aa " style= "display:none; "> <span class= "l " onclick= "javascript:addattachment(this); "> &nbsp;&nbsp;增加附件 </span> </div> </td> '
+
' </tr> </tbody> </table> ' + ' <!--/end Attachment--> ' ;
document.write(attHTML);
if(maxatts)
MAX_attachments = maxatts;
}


//////////Attachments Operations!
var VT_attachments = 0;
var MAX_attachments = 5;
var attach=null;
function initattachment(me)
{
var ia = me.parentNode;
var att = ia.parentNode;
if(att.id != 'att ')
return;

Ohidden(ia);
var aa = gObId( 'aa ');
Oshow(aa);
addattachment(aa);
}