인터넷정보

입력 상자 증가 폼

알 수 없는 사용자 2007. 10. 18. 14:16
<xmp style="font-size:10pt;">
-----------------------------------------------------------------
<html><head><title> [DHTML]입력양식 증감 예- NS, IE 호환 </title>
<script language="JavaScript">
<!--
/**
** 작성일: 2002-12-27
**/
var divTotal=20
var formName="myForm"
var eleName="ele"

//var ns4=document.layers?1:0
var ie=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

function SetCross(divID)
{
    if(ie) divObj=document.all[divID]
    else if (ns6) divObj=document.getElementById(divID)
    //else if (ns4) divObj=document.layers[divID]
    this.divObj=divObj
}
function setObj(){this.total=0}
var divs=new setObj()

function printDivs(num)
{
    if(num<=1) num=1
    oldTotal=divs.total
    str='<form name="'+formName+'">'
    for(i=0;i<num;i++)
    {
        val=''
        if(i<oldTotal)
        {
            val=eval("document."+formName+"."+eleName+i+".value")
        }
        str+=(i+1)+' <input type=text name="'+eleName+i+'" value="'+val+'">'
        divs.total=i+1
    }
    str+='</form>'
    my=new SetCross("myDiv")
    my.divObj.innerHTML=str
    document.cForm.chg.selectedIndex=divs.total
}


//-->
</script>
</head>

<body onLoad="printDivs(1)">

<p>
<b>[DHTML]입력양식 증감 예</b>
<b>TEST</b>: NS6+, IE5.5+
</p>

<table border=0>
<form name=cForm>
<tr><td>
<select name=chg onChange="printDivs(this.selectedIndex)">
<script>
opt="<option>선택";
for(i=1;i<=divTotal;i++)
{
    opt+="<option>"+i
}
document.write(opt);
</script>
</select> 입력 박스 증감 선택
</td></tr>
</form>
<tr><td id=myDiv><!-- 증감된 입력 폼이 들어갈 자리 --></td></tr>
<tr><td>선택된 수만큼 입력박스가 증가되거나 감소됩니다.</td></tr>
</table>

</body>
</html>
-----------------------------------------------------------------
</xmp>
<html><head><title> [DHTML]입력양식 증감 예- NS, IE 호환 </title>
<script language="JavaScript">
<!--
/**
** 작성일: 2002-12-27
**/
var divTotal=20
var formName="myForm"
var eleName="ele"

//var ns4=document.layers?1:0
var ie=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0

function SetCross(divID)
{
    if(ie) divObj=document.all[divID]
    else if (ns6) divObj=document.getElementById(divID)
    //else if (ns4) divObj=document.layers[divID]
    this.divObj=divObj
}
function setObj(){this.total=0}
var divs=new setObj()

function printDivs(num)
{
    if(num<=1) num=1
    oldTotal=divs.total
    str='<form name="'+formName+'">'
    for(i=0;i<num;i++)
    {
        val=''
        if(i<oldTotal)
        {
            val=eval("document."+formName+"."+eleName+i+".value")
        }
        str+=(i+1)+' <input type=text name="'+eleName+i+'" value="'+val+'">'
        divs.total=i+1
    }
    str+='</form>'
    my=new SetCross("myDiv")
    my.divObj.innerHTML=str
    document.cForm.chg.selectedIndex=divs.total
}


//-->
</script>
</head>

<body onLoad="printDivs(1)">

<p>
<b>[DHTML]입력양식 증감 예</b>
<b>TEST</b>: NS6+, IE5.5+
</p>

<table border=0>
<form name=cForm>
<tr><td>
<input type=reset value=' Reset ' onClick="printDivs(1)">
<select name=chg onChange="printDivs(this.selectedIndex)">
<script>
opt="<option>선택";
for(i=1;i<=divTotal;i++)
{
    opt+="<option>"+i
}
document.write(opt);
</script>
</select> 입력 박스 증감 선택
</td></tr>
</form>
<tr><td id=myDiv><!-- 증감된 입력 폼이 들어갈 자리 --></td></tr>
<tr><td>선택된 수만큼 입력박스가 증가되거나 감소됩니다.</td></tr>
</table>

</body>
</html>
반응형