首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

请问一有关问题

2012-02-26 
请教一问题!functionaddfile(){varopdocument.createElement( input )op.name t1 op.type file op.i

请教一问题!
function   addfile()
{
var   op   =   document.createElement( 'input ');
op.name= 't1 ';
op.type= 'file ';
op.id= 't1 ';
document.body.appendChild(op);
}
</script>
<button   onclick= 'addfile() '> 附件 </button>

这样虽说可以插入file可是,它始终只能插在本来有的form之外
这对以后表单提交带来很多不便!
如果我欲想将file新增在
<form   name= "form1 "   id= "form1 "   action= " "   method= "post ">
</form> 之间如何实现呢?请指教,谢谢!


[解决办法]
function addfile()
{
var op = document.createElement( 'input ');
op.name= 't1 ';
op.type= 'file ';
op.id= 't1 ';
document.getElementById( 'form1 ').appendChild(op);//ocument.body.appendChild(op);
}


[解决办法]
document.getElementById( 'form的id ').appendChild(op);

热点排行