JS高手帮看一下 关于JS增加DIV的问题
以下代码是从一个网站上拿下来的但是只可以增加2个改了很多次都不成功想改成可以上传4个请高手指点一下<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML...
以下代码是从一个网站上拿下来的 但是只可以增加2个 改了很多次 都不成功
想改成可以上传4个 请高手指点一下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="JavaScript">
//添加图片附件
function add_file()
{
document.getElementById('file2').style.display="";
//document.getElementById('titlepic2file').disabled=false;
document.getElementsByName('titlepic2file')[0].disabled=false;
if(document.getElementById('file_flag').value==1)
{
document.getElementById('file3').style.display="";
//document.getElementById('titlepic3file').disabled=false;
document.getElementsByName('titlepic3file')[0].disabled=false;
}
document.getElementById('file_flag').value=1;
}
//删除图片附件
function del_file2()
{
document.getElementById('file2').style.display="none";
//document.getElementById('titlepic2file').disabled=true;
document.getElementsByName('titlepic2file')[0].disabled=true;
}
function del_file3()
{
document.getElementById('file3').style.display="none";
//document.getElementById('titlepic3file').disabled=true;
document.getElementsByName('titlepic3file')[0].disabled=true;
}
</script>
<input type="file" name="titlepicfile" size="28"><input type="button" class="addpic" onclick="add_file()" value="" />
<div id="file2" style="display:none"><input type="file" name="titlepic2file" size="28"> <a href="javascript:del_file2()">[ 移除 ]</a><input type="hidden" name="file_flag" id="file_flag" value="0" /></div>
<div id="file3" style="display:none"><input type="file" name="titlepic3file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
</body>
</html>
希望高手可以帮改一下 改成可以增加成5个的 展开
想改成可以上传4个 请高手指点一下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script language="JavaScript">
//添加图片附件
function add_file()
{
document.getElementById('file2').style.display="";
//document.getElementById('titlepic2file').disabled=false;
document.getElementsByName('titlepic2file')[0].disabled=false;
if(document.getElementById('file_flag').value==1)
{
document.getElementById('file3').style.display="";
//document.getElementById('titlepic3file').disabled=false;
document.getElementsByName('titlepic3file')[0].disabled=false;
}
document.getElementById('file_flag').value=1;
}
//删除图片附件
function del_file2()
{
document.getElementById('file2').style.display="none";
//document.getElementById('titlepic2file').disabled=true;
document.getElementsByName('titlepic2file')[0].disabled=true;
}
function del_file3()
{
document.getElementById('file3').style.display="none";
//document.getElementById('titlepic3file').disabled=true;
document.getElementsByName('titlepic3file')[0].disabled=true;
}
</script>
<input type="file" name="titlepicfile" size="28"><input type="button" class="addpic" onclick="add_file()" value="" />
<div id="file2" style="display:none"><input type="file" name="titlepic2file" size="28"> <a href="javascript:del_file2()">[ 移除 ]</a><input type="hidden" name="file_flag" id="file_flag" value="0" /></div>
<div id="file3" style="display:none"><input type="file" name="titlepic3file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
</body>
</html>
希望高手可以帮改一下 改成可以增加成5个的 展开
1个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
</head>
<body>
<script language="JavaScript">
//添加图片附件
function add_file()
{
if(document.getElementById('file_flag').value==0){
document.getElementById('file2').style.display="";
document.getElementsByName('titlepic2file')[0].disabled=false;
document.getElementById('file_flag').value=1;
}else if(document.getElementById('file_flag').value==1)
{
document.getElementById('file3').style.display="";
document.getElementsByName('titlepic3file')[0].disabled=false;
document.getElementById('file_flag').value=2;
}else if(document.getElementById('file_flag').value==2)
{
document.getElementById('file4').style.display="";
document.getElementsByName('titlepic4file')[0].disabled=false;
document.getElementById('file_flag').value=3;
}else if(document.getElementById('file_flag').value==3)
{
document.getElementById('file5').style.display="";
document.getElementsByName('titlepic5file')[0].disabled=false;
document.getElementById('file_flag').value=4;
}else if(document.getElementById('file_flag').value==4)
{
document.getElementById('file6').style.display="";
document.getElementsByName('titlepic6file')[0].disabled=false;
document.getElementById('file_flag').value=5;
}
}
//删除图片附件
function del_file2()
{
document.getElementById('file2').style.display="none";
document.getElementsByName('titlepic2file')[0].disabled=true;
}
function del_file3()
{
document.getElementById('file3').style.display="none";
document.getElementsByName('titlepic3file')[0].disabled=true;
}
function del_file4()
{
document.getElementById('file4').style.display="none";
document.getElementsByName('titlepic4file')[0].disabled=true;
}
function del_file5()
{
document.getElementById('file5').style.display="none";
document.getElementsByName('titlepic5file')[0].disabled=true;
}
function del_file6()
{
document.getElementById('file6').style.display="none";
document.getElementsByName('titlepic6file')[0].disabled=true;
}
</script>
<input type="file" name="titlepicfile" size="28"><input type="button" class="addpic" onclick="add_file()" value="" />
<div id="file2" style="display:none"><input type="file" name="titlepic2file" size="28"> <a href="javascript:del_file2()">[ 移除 ]</a><input type="hidden" name="file_flag" id="file_flag" value="0" /></div>
<div id="file3" style="display:none"><input type="file" name="titlepic3file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
<div id="file4" style="display:none"><input type="file" name="titlepic4file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
<div id="file5" style="display:none"><input type="file" name="titlepic5file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
<div id="file6" style="display:none"><input type="file" name="titlepic6file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
</head>
<body>
<script language="JavaScript">
//添加图片附件
function add_file()
{
if(document.getElementById('file_flag').value==0){
document.getElementById('file2').style.display="";
document.getElementsByName('titlepic2file')[0].disabled=false;
document.getElementById('file_flag').value=1;
}else if(document.getElementById('file_flag').value==1)
{
document.getElementById('file3').style.display="";
document.getElementsByName('titlepic3file')[0].disabled=false;
document.getElementById('file_flag').value=2;
}else if(document.getElementById('file_flag').value==2)
{
document.getElementById('file4').style.display="";
document.getElementsByName('titlepic4file')[0].disabled=false;
document.getElementById('file_flag').value=3;
}else if(document.getElementById('file_flag').value==3)
{
document.getElementById('file5').style.display="";
document.getElementsByName('titlepic5file')[0].disabled=false;
document.getElementById('file_flag').value=4;
}else if(document.getElementById('file_flag').value==4)
{
document.getElementById('file6').style.display="";
document.getElementsByName('titlepic6file')[0].disabled=false;
document.getElementById('file_flag').value=5;
}
}
//删除图片附件
function del_file2()
{
document.getElementById('file2').style.display="none";
document.getElementsByName('titlepic2file')[0].disabled=true;
}
function del_file3()
{
document.getElementById('file3').style.display="none";
document.getElementsByName('titlepic3file')[0].disabled=true;
}
function del_file4()
{
document.getElementById('file4').style.display="none";
document.getElementsByName('titlepic4file')[0].disabled=true;
}
function del_file5()
{
document.getElementById('file5').style.display="none";
document.getElementsByName('titlepic5file')[0].disabled=true;
}
function del_file6()
{
document.getElementById('file6').style.display="none";
document.getElementsByName('titlepic6file')[0].disabled=true;
}
</script>
<input type="file" name="titlepicfile" size="28"><input type="button" class="addpic" onclick="add_file()" value="" />
<div id="file2" style="display:none"><input type="file" name="titlepic2file" size="28"> <a href="javascript:del_file2()">[ 移除 ]</a><input type="hidden" name="file_flag" id="file_flag" value="0" /></div>
<div id="file3" style="display:none"><input type="file" name="titlepic3file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
<div id="file4" style="display:none"><input type="file" name="titlepic4file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
<div id="file5" style="display:none"><input type="file" name="titlepic5file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
<div id="file6" style="display:none"><input type="file" name="titlepic6file" size="28"> <a href="javascript:del_file3()">[ 移除 ]</a></div>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询