######################################### regist_form.asp #################################################
<
%@Language="VBScript" CODEPAGE="65001"%>
<%Response.ContentType="text/html;charset=UTF-8"%>
<!--#include file="include/dbcon.asp" -->
<form name="myform" action="imgdata_ok.asp" method="post">
<DIV id="layer1">
파일<input type="text" name="boardnumber"><input type="text" name="boardmemberid"><input type="file" name="boardimagename"><input type="text" name="boardimagesize">
</DIV>
<!------------------------------------------------------------------>
<DIV>
<a href="javascript:addItem();">추가</a>
<a href="javascript:mItem();">삭제</a>
( 좌측의 추가 버튼을 클릭하면 여러개를 입력할수있습니다 )
</DIV>
<!------------------------------------------------------------------>
<input type="submit" value="upload" />
<script language="javascript">
var noTh = 1;
var maXnoTh = 20;
function defaultItem() {
noTh = 1;
layer1.innerHTML += "<div>파일<input type='text' name='boardnumber' value='1'>input type='text' name='boardmemberid' value='작성자아이디'><input type='file' name='boardimagename' value ='파일름' /><input type='text' name='boardimagesize' value ='이미지사이즈'></div>";}
function addItem()
{
if(maXnoTh <= noTh)
{
alert('더이상 추가하실수 없습니다.');
return;
}
noTh = noTh + 1;
layer1.innerHTML += "<div>파일<input type='text' name='boardnumber'>"+"<input type='text' name='boardmemberid'>"+"<input type='file' name='boardimagename' />"+"<input type='text' name='boardimagesize'></div>";}
function mItem() {
if(noTh <= 1) {
alert('더이상 삭제하실수 없습니다.');
return;
}
else {
noTh--; // 기존 value 값을 저장합니다.
value1 = new Array();
value2 = new Array();
for(i=1; i <= noTh; i++){
form = document.myform;
value1[i] = noTh; //value2[i] = form['ea'+i].value;
} // innerHTML 을 새로 생성합니다.
layer1.innerHTML = '';
for(i=1; i <= noTh; i++) {
layer1.innerHTML += "<div>파일<input type='text' name='boardnumber'>"+"<input type='text' name='boardmemberid'>"+"<input type='file' name='boardimagename' />"+"<input type='text' name='boardimagesize'></div>";}
}
}
//-->
</script>
</form>
######################################### regist_form_ok.asp #################################################
<%
boardnumber = request.Form("boardnumber")
boardmemberid = request.Form("boardmemberid")
boardimagename = request.Form("boardimagename")
boardimagesize = request.Form("boardimagesize")
boardnum = Split(boardnumber,",")
boarid = Split(boardmemberid,",")
imgname = Split(boardimagename,",")
imgsize = Split(boardimagesize,",")
SQL = "Select Max(ImgNum) from Imgdata"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL, dbcon
SQL = ""
For i = 0 To UBound(boardnum)
SQL = SQL & "INSERT INTO Imgdata(BoardNumber, BoardMemberID, BoardImageName, BoardImageSize) VALUES"
SQL = SQL & "('" &boardnum(i)& "'"
SQL = SQL & ",'" &boarid(i)& "'"
SQL = SQL & ",'" &imgname(i)& "'"
SQL = SQL & ",'" &imgsize(i)& "');"
next
response.write sql
dbcon.Execute SQL
rs.Close
dbcon.close
Set rs = Nothing
Set db = Nothing
Response.redirect "imgdata.asp"
%>