2015년 4월 14일 화요일

자주 사용하는 JAVA Script Sample (Useful JAVA Script)

           
// ############################################################################
// 1. submit 처리 창 참고 060224
if() {

   f.target=this.window.name; // ★★★
   f.action="order3.php";
   return true;
} else {
// 카드, 계좌이체
    f.target = "ifm";
    f.action = "order3_1.php"; // 디비 데이터 입력 , 전자결제 창 로드
   return true;
             
}
           
// ############################################################################
// 2. obj 참고
function down (inx,obj) {
   if (parseInt(obj.value) == 1)
   return;
   
   obj.value = parseInt (obj.value) - 1;
  return;
}
           
// ############################################################################
// 3. radiobutton 060224
var paym;

 //radiobutton -> pay_method

for(i=0;i<f.pay_method.length;i++) {
   if(f.pay_method[i].checked) paym=f.pay_method[i].value;
}
if(paym == "online") { ..................................
// ----------------------------------------------------------------------------
function appChk(f) {

   var chknum = f.elements.length;
   var selcnt=0;
for(var i=0;i<chknum;i++) {
   if(f.elements[i].checked == true && f.elements[i].name == "sel[]") {
       selcnt=selcnt+1;
   }
} // end for 
           
 if(selcnt == 0) {
   alert("현금 영수증 신청할 리스트를 하나이상 선택하세요. ");
   return;
 } else { 
   f._mode.value="create";
   f.target="_blank";
   f.submit();
 }
// ############################################################################
// 4. 개체 존재여부
           
if(document.all["res_point_pay"]) {
   if(!f.res_point_pay.value) 
   f.res_point_pay.value=0;
 if(!IsNumber(f.res_point_pay.name)) {
   alert("사용적립금은 숫자로 입력하세요");
   f.res_point_pay.focus();
   f.res_point_pay.focus();
   return false;
   }
 } // end if

          
// 정규표현식 사용한 함수

// 1. 특수문자. 공백제거 
function repSpcChr(obj) {
               
  if(!obj.value) return;
  var denyChars = "~`!@#$%^&*()_+|=-{}][';:\"\\/.,<>?";
  var charNum=0;
  var retval="";
  var chr;
  for (var inx = 0; inx < obj.value.length; inx++) {
        if ((chr = denyChars.indexOf(obj.value.charAt(inx))) != -1)
        charNum++;
        else retval += obj.value.substr(inx,1);
 } // end for
           
 var rp = /\s/gi; // regular expression
 retval = retval.replace(rp,""); 
 obj.value = retval;
 return;
} // end func
// 2. 기타 체크

/**
* 입력값이 사용자가 정의한 포맷 형식인지 체크
* 자세한 format 형식은 자바스크립트의 'regular expression'을 참조
*/
function isValidFormat(input,format) {
if (input.value.search(format) != -1) {
return true; //올바른 포맷 형식
}
return false;
}

/**
* 입력값이 이메일 형식인지 체크
* ex) if (!isValidEmail(form.email)) {
* alert("올바른 이메일 주소가 아닙니다.");
* }
*/
function isValidEmail(input) {
// var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
return isValidFormat(input,format);
}

/**
* 입력값이 전화번호 형식(숫자-숫자-숫자)인지 체크
*/
function isValidPhone(input) {
var format = /^(\d+)-(\d+)-(\d+)$/;
return isValidFormat(input,format);
}




// 새창 강제로 닫기

// body 안쪽에 스크립트 처리 ^^ 
<script>window.opener = window.location.href; self.close();</script>

// PHP 데이터 전송
function updCartQty(frm){
     var nums = frm.elements.length;
     frm.action="/inc/updCartQty.htm";
     frm.submit();
} // end func
           
function selDelCart(frm) {
 
  var nums = frm.elements.length;
  var chknums = 0;
 //alert(document.cfrm.elements[3].type);
 for(i=0;i<nums;i++) {
        if(frm.elements[i].type == "checkbox" && frm.elements[i].checked == true) {
   
             chknums++;
          }
  } // end for
           
 if(chknums == 0) {
        alert('삭제할 주문 리스트를 선택하세요.');
          return;
  } else {
        frm.action="/inc/selDelCart.htm";
        frm.submit();
  } // end if
           
} // end func 



ⓐ checkbox
html : <input type="checkbox" name="del_bkcd[]" value="<?=$data[bk_cd]?>" checked>
처리 php : foreach($del_bkcd as $val) 

ⓑ text 
html : <input name="upd_qty[<?=$data[bk_cd]?>]" type="text" class="input_st01" value="<?=$data[b_qty]?>"
처리 php : foreach($upd_qty as $key = > $val)
// COOKIE 를 굽자..^^  
function setCookie( name, value, expiredays )
{
        var todayDate = new Date();
        todayDate.setDate( todayDate.getDate() + expiredays );

        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
           
function getCookie( name )
{
      var nameOfCookie = name + "=";
      var x = 0;

      while ( x <= document.cookie.length )
      {
             var y = (x+nameOfCookie.length);

             if ( document.cookie.substring( x, y ) == nameOfCookie ) {
               if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                    endOfCookie = document.cookie.length;
               return unescape( document.cookie.substring( y, endOfCookie ) );
             }

             x = document.cookie.indexOf( " ", x ) + 1;

             if ( x == 0 )  break;
     }

     return "";

}


### 사용 예)

setCookie( "Notice", "done" , 1); 

if ( getCookie( "Notice" ) != "done" )
{
noticeWindow  =  window.open('pop3.htm','notice','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400');
noticeWindow.opener = self;
}

// KSNET 결제 창 콜 함수


<!--
             /*goOpen() - 함수설명 : 결재에 필요한 기본거래정보들을 세팅하고 kspay통합창을 띄웁니다.*/
     function goOpen() 
     { 
             /*kspay통합창에 전달해줄 인자값들을 세팅합니다.*/
             document.authFrmFrame.sndOrdernumber.value     = document.KSPayWeb.sndOrdernumber.value;
             document.authFrmFrame.sndGoodname.value        = document.KSPayWeb.sndGoodname.value;
             document.authFrmFrame.sndInstallmenttype.value = document.KSPayWeb.sndInstallmenttype.value;
             document.authFrmFrame.sndAmount.value          = document.KSPayWeb.sndAmount.value;
             document.authFrmFrame.sndOrdername.value       = document.KSPayWeb.sndOrdername.value;
             document.authFrmFrame.sndAllregid.value        = document.KSPayWeb.sndAllregid.value;
             document.authFrmFrame.sndEmail.value           = document.KSPayWeb.sndEmail.value;
             document.authFrmFrame.sndMobile.value          = document.KSPayWeb.sndMobile.value;
             document.authFrmFrame.sndInteresttype.value    = document.KSPayWeb.sndInteresttype.value;
             document.authFrmFrame.sndCurrencytype.value    = document.KSPayWeb.sndCurrencytype.value;
             document.authFrmFrame.sndWptype.value          = document.KSPayWeb.sndWptype.value;
             document.authFrmFrame.sndAdulttype.value       = document.KSPayWeb.sndAdulttype.value;
             var height_ = 420;
             var width_ = 400;
             var left_ = screen.width;
             var top_ = screen.height;
   
             left_ = left_/2 - (width_/2);
             top_ = top_/2 - (height_/2);
   
             /*kspay통합창을 띄워줍니다.*/
             src = window.open('about:blank','AuthFrmUp',
             'height='+height_+',width='+width_+',status=yes,scrollbars=no,resizable=no,left='+left_+',top='+top_+'');

             document.authFrmFrame.target = 'AuthFrmUp';
             document.authFrmFrame.action ='https://kspay.ksnet.to/store/KSPayWebV1.3/KSPayWeb.jsp';
             document.authFrmFrame.submit();

     }
 /*goResult() - 함수설명 : 결재완료후 결과값을 지정된 결과페이지(result.php)로 전송합니다.*/
      function goResult()
      {
             document.KSPayWeb.target = "";
             document.KSPayWeb.submit();
      }
 /*paramSet() - 함수설명 : 결재완료후 (KSPayRcv.php로부터)결과값을 받아 지정된 결과페이지(result.php)로 전송될 form에 세팅합니다.*/
      function paramSet(authyn,trno,trdt,trtm,authno,ordno,msg1,msg2,amt,temp_v,isscd,aqucd,remark,result,cardno,cardinst,etrans_bank)
      {
             document.KSPayWeb.reAuthyn.value = authyn;
             document.KSPayWeb.reTrno.value = trno  ;
             document.KSPayWeb.reTrddt.value = trdt  ;
             document.KSPayWeb.reTrdtm.value = trtm  ;
             document.KSPayWeb.reAuthno.value = authno;
             document.KSPayWeb.reOrdno.value = ordno ;
             document.KSPayWeb.reMsg1.value = msg1  ;
             document.KSPayWeb.reMsg2.value = msg2  ;
             document.KSPayWeb.reAmt.value = amt   ;
             document.KSPayWeb.reTemp_v.value = temp_v;
             document.KSPayWeb.reIsscd.value = isscd ;
             document.KSPayWeb.reAqucd.value = aqucd ;
             document.KSPayWeb.reRemark.value = remark;
             document.KSPayWeb.reResult.value = result;
             document.KSPayWeb.reCardno.value = cardno;
             document.KSPayWeb.reCardinst.value = cardinst;
             document.KSPayWeb.reEtrans_bank.value = etrans_bank;
           
       }
-->
 
// clipboard 복사

function clipboardcopy(msg){
   window.clipboardData.setData('Text',msg);
   alert (msg+" 클립보드에 복사 되었습니다.");
 }

// -----------------------------------------------------------------




function exe_copy(name) 
 
var obj = eval("document.all." + name); 
var doc = obj.createTextRange(); 
doc.select(); 
doc.execCommand('copy'); 
 
alert('클립보드에 복사 되었습니다.'); 
 
 

 
function exe_paste(name) 
 
var obj = eval("document.all." + name); 
var doc = obj.createTextRange(); 
doc.select(); 
doc.execCommand('paste'); 
 
alert('클립보드의 내용이 붙여넣기 되었습니다.'); 
 

// CSS 제어하기 
          
<HTML>
<HEAD>
<TITLE> Testing.. </TITLE>
<style>
    .c0{height:10;filter:blur(add:0,direction:315,strength:3);POSITION:relative;TOP:2px;LEFT:2px;}
    .c1{}
 </style> 
<script>

 // function
  function ps(v){
     document.getElementById('d').className='c'+v;
  }


  function mv(dis) {
    document.getElementById('d').style.marginLeft=dis+"px";
  } 
 // event..
   document.onmousedown=function(){ps(0);}
   document.onmouseup=function(){ps(1);}
 </script>
 </HEAD>
<BODY>
 <div id=d >test</div>
 </BODY>
 </HTML>
// checkbox(체크박스) 선택 반전 
           
           
           
<script type="text/JavaScript"> 

      function chkBox(bool) { // 전체선택/해제 
               var obj = document.getElementsByName("chk[]"); 
               for (var i=0; i<obj.length; i++) obj[i].checked = bool; 
       } 

       function revBox() { // 전체반전 
             var obj = document.getElementsByName("chk[]"); 
             for (var i=0; i<obj.length; i++) obj[i].checked = !obj[i].checked; 
        } 

</script> 
<table border=1> 
             <tr bgcolor=#efefef> 
   <td><INPUT type=checkbox onclick=chkBox(this.checked)> 선택</td> 
   </tr> 
   <tr><td><INPUT type=checkbox name=chk[] value=100> 이효리</td></tr> 
   <tr><td><INPUT type=checkbox name=chk[] value=200> 성유리</td></tr> 
   <tr><td><INPUT type=checkbox name=chk[] value=300> 이진</td></tr> 
   <tr><td><INPUT type=checkbox name=chk[] value=400> 옥주현</td></tr> 
   </table> 
<INPUT type=button value="전체반전" onclick=revBox()> 
 
           
          
// tr OnMouseOver , OnMouseOut

<tr onMouseOver="this.style.backgroundColor='#F5F5F5'" onMouseOut="this.style.backgroundColor=''" >

</tr>
// Banner Sample 


<script language="javascript">
<!--
now4 = new Date();
switch(now4.getSeconds() % 2) {

case 0:
document.write('<a href="/Category/FTCategoryMain02.aspx?CategoryNumber=008001015125"><img src="http://image.yes24.com/images/05_Welcome/Banner/CenterMini/Bt070226_1.gif" alt="엔프라니 주고 또 주고~할인에 트리플 사은증정까지" width="180" height="48" border="0"></a>');
break;
case 1:
document.write('<a href="/Category/FTCategoryMain02.aspx?CategoryNumber=008005145"><img src="http://image.yes24.com/images/05_Welcome/Banner/CenterMini/Bt070226_2.gif" alt="YES24 단독 코리아나 8종팩키지 무료 증정" width="180" height="48" border="0"></a>');
break;

};
//-->
</script>
// 이동 관련 name 테그 사용, 좌우 프레임 같이 이동

function vwbkinfo(b_url,j) {


top.mfrm.location.href=b_url;
location.href="#"+j


}

// 다음칸 이동

function nxtItem()
{
var str = document.jumin.jumin1.value.length;
if(str == 6)
document.jumin.jumin2.focus();
}

<input name="jumin1" size="6" OnKeyUp="nxtItem();" maxlength="6"> 
- <input name="jumin2" size="7" maxlength="7">

// 숫자에 "," 표시를 위한 자바스크립트
function FormatNumber(value)
{
if(!isNaN(value))
{
valueS = value.toString();
var len = valueS.length;
var valueN = "";

for(var i=len;i>0;i--)
{

if(i!=len && i%3 == len%3)
{
valueN = ","+valueN;
valueN = valueS.substring(i,i-1).concat(valueN);
}
else
valueN = valueS.substring(i,i-1).concat(valueN);

}
}

return valueN;
}
//숫자에 ","빼기

function FormatUnNumber(value)
{
if (value != '')
{
return value.replace(/,/g,''); 

}else
return '';
}
//숫자를 공백으로 바꾸어주기

function ZeroToNull(value)
{
if(!isNaN(value))
{
if(value == 0) return "";
}

return value;
}

 

// 20050529 ##################################################################################################

// checkbox -->>> f.checkboxname.length 인식 안됨

function revchk() {
var f = document.signform;
var chknum = f.elements.length;

for(var i=0;i<chknum;i++) {
if(f.elements[i].checked == true) f.elements[i].checked = false;
else f.elements[i].checked = true;
} // end for


}

 

// radio 버튼 참고... . 

function putcart() {
// radio box 의 배열 처리 참고. . . 
// document.form.radioboxname.length 존재할시 배열 즉 같은이름으로 여러개 존재한다는뜻.. 
// javascript에서는 if 문으로 처리해서 처리. .

var fm = document.apxform;
bk_cd = new Array(5);
bk_cd[0]=$bk_cd;

if(fm.selapx2.length) { 
for(i=0;i<fm.selapx2.length;i++) {
if(fm.selapx2[i].checked) bk_cd[1]=fm.selapx2[i].value;
}
} else bk_cd[1] = fm.selapx2.value;

if(fm.selapx3.length) {
for(i=0;i<fm.selapx3.length;i++) {
if(fm.selapx3[i].checked) bk_cd[2]=fm.selapx3[i].value;
}
} else bk_cd[2] = fm.selapx3.value;

if(fm.selapx4) {
if(fm.selapx4.length) { // 같은 네임으로 된 radio 개체가 하나뿐이라는 것.. 배열 x 
for(i=0;i<fm.selapx4.length;i++) {
if(fm.selapx4[i].checked) bk_cd[3]=fm.selapx4[i].value;
} // end for
} else bk_cd[3] = fm.selapx4.value;
}

// testing
//alert(bk_cd[3]);
 

if(fm.selapx5) {
if(fm.selapx5.length) { // 개체 길이가 있으면 배열 처리 >> radio 특징

for(i=0;i<fm.selapx5.length;i++) {
if(fm.selapx5[i].checked) bk_cd[4]=fm.selapx5[i].value;
}
} else bk_cd[4] = fm.selapx5.value;
}
window.open('bookcart_input.php3?bk_cd='+bk_cd+'&bk_nm=','','width=300,height=230,left=200,top=200');
}

//slelect menu [셀렉트 메뉴] 

function selectIt() {
var str = zipsearch.intro_cd.options[zipsearch.intro_cd.selectedIndex].text;
// frm.intro_cd.selectedIndex = 0; // 지정시 opener.document.memberform.addr1.value = str.substring(10,60);
opener.document.memberform.mail_no1.value = str.substring(1,4);
opener.document.memberform.mail_no2.value = str.substring(5,8);
self.close();
}

 

function openImage(file, width, height) {
var window_left = (screen.width-640)/2;
var window_top = (screen.height-480)/2;

image = window.open('', '', 'width=' + width + ', height=' + height + ', scrollbars=no,top=' + window_top + ',left=' + window_left + ''); 
image.document.write('<body topmargin=0 leftmargin=0 marginheight=0 marwidth=0>');
image.document.write('<a href=javascript:window.close() title=창닫기>');
image.document.write('<img src=\"' + file + '\" width=' + width + ', height=' + height + ' border=0></a></body>');
}

// 그림 이미지 비례 조정

function resizeImg(target_img,s_width,s_height)
{
var newX;
var newY;
var newHeight;
var newWidth;
var maxWidth = s_width;
var maxHeight = s_height;
var newImg = new Image();
newImg.src = target_img.src;
imgw = newImg.width;
imgh = newImg.height;
if (imgw > maxWidth || imgh > maxHeight)
{
if (imgw > imgh)
{
if (imgw > maxWidth)
newWidth = maxWidth;
else
newWidth = imgw;
newHeight = Math.round((imgh * newWidth) / imgw);
}
else
{
if (imgh > maxHeight)
newHeight = maxHeight;
else
newHeight = imgh;
newWidth = Math.round((imgw * newHeight) / imgh);
}
}
else
{
newWidth = imgw;
newHeight = imgh;
}
newX = maxWidth / 2 - newWidth / 2;
newY = maxHeight / 2 - newHeight / 2;
target_img.onload = null;
target_img.src = newImg.src;
target_img.width = newWidth;
target_img.height = newHeight;
}
function check_ID_Window(ref) {
var id = eval(document.frm_reg.id);

if(!id.value) {
alert('아이디(ID)를 입력하신 후에 확인하세요!');
id.focus();
return;
} else {
ref = ref + "&id=" + id.value;
var window_left = (screen.width-640)/2;
var window_top = (screen.height-480)/2;
window.open(ref,"checkIDWin",'width=393,height=246,status=no,top=' + window_top + ',left=' + window_left + '');
}
}
function check_photo(frm){

if (frm.picture.value) {
document.preview.src = frm.picture.value;
}
}

// 주민번호 체크

function jumin()
{
var form = document.frm_reg;

jumin1=form.jumin1.value;
jumin2=form.jumin2.value;
a=jumin1+jumin2; 
ju=new Array(13);
ch=new Array(2,3,4,5,6,7,8,9,2,3,4,5);
sum=0;

for(i=0;i<12;i++){
ju[i]=a.charAt(i);
ju[i]=eval(ju[i]);
sum=sum+(ju[i]*ch[i]);
}
sum=11-(sum%11);

if(9<sum){
sum=sum%10;
}
ju[12]=a.charAt(12);
ju[12]=eval(ju[12]);

if(ju[12]!=sum){

alert("주민번호를 정확히 입력해 주세요!");
form.jumin1.value="";
form.jumin2.value="";
form.jumin1.focus();
}

function jump_field()
{
var str = document.frm_reg.jumin1.value.length;
if(str == 6)
document.frm_reg.jumin2.focus();
}

function IsID(formname) {
var form = eval("document.frm_reg." + formname);

if(form.value.length < 4 || form.value.length > 12) {
return false;
}
for(var i = 0; i < form.value.length; i++) {
var chr = form.value.substr(i,1); 
if((chr < '0' || chr > '9') && (chr < 'a' || chr > 'z')) {
return false;
}
}
return true; 
}
function IsPW(formname) {
var form = eval("document.frm_reg." + formname);

if(form.value.length < 4 || form.value.length > 10) {
return false;
}
for(var i = 0; i < form.value.length; i++) {
var chr = form.value.substr(i,1); 
if((chr < '0' || chr > '9') && (chr < 'a' || chr > 'z') && (chr < 'A' || chr > 'Z')) {
return false;
}
}
return true; 
}

//이메일 체크

function isEmailAddr(EMAIL)
{
var result = false
var theStr = new String(EMAIL)
var index = theStr.indexOf("@");
if (index > 0)
{
var pindex = theStr.indexOf(".",index);
if ((pindex > index+1) && (theStr.length > pindex+1))
result = true;
}
return result;
}

function checkLength(item, next_item, num)
{
bName = navigator.appName;
if ( bName == "Netscape" ) return;
if ( item.value.length == num ) next_item.focus();
}

// 숫자 입력 체크

function cfmnumic(fl,len) {
tmp = fl.name ;
t = fl.value ;

if (fl.value=="") return false;

if (fl.value.length < len) {
alert("너무 짧습니다. 다시 입력해주세요.") ;
fl.focus() ;
return false ;
}

for(i=0 ; i < t.length ; i++) 
if (t.charAt(i) < '0' || t.charAt(i) > '9') {
alert("숫자만 입력해주세요.") ;
fl.focus() ;
return false ;
}

// return false;
return true;
}

function sms_not() {
alert("받는 이의 핸드폰 번호가 입력되지 않았습니다.");
return;
}

function ugb_not() {
alert("정회원 전용입니다.\n이 서비스를 이용하실려면 정회원으로 전환 하셔야 합니다");
return;
}

function ugb_Student_not() {
alert("신청하신 선생님은 준회원 선생님입니다. \n준회원 선생님은 과외신청하기만 접수됩니다. \n과외연결을 원하시면 과외신청하기 버튼을 클릭하세요.");
return;
}
function userTal() {

var fwrite = document.frm_reg;

fwrite.action = "/classes/tal_reg.php?userTal=ok&no=<?=$no?>&table=<?=$table?>";
fwrite.submit();
}

function userTal_S() {

var fwrite = document.frm_reg;

fwrite.action = "/classes/tal_reg.php?userTal=stuok&no=<?=$no?>&table=<?=$table?>";
fwrite.submit();
}

function userTal_M() {

var fwrite = document.frm_reg;

fwrite.action = "/classes/tal_reg.php?userTal=me&no=<?=$no?>&table=<?=$table?>";
fwrite.submit();
}

function findGa_reg() {
document.search.submit();
}

function ugb_member() {
alert("회원 전용입니다.\n이 서비스를 이용하실려면 로그인을 하셔야 합니다");
return;
}

function isUniv(dig, cmt) {
var didi = '`-=\[];\',./~!@#$%^&*()_+|{}:\"<>? ';

for(i = 0; i < dig.value.length; i++) {
if(didi.indexOf(dig.value.substring(i,i+1)) != -1){
alert(cmt+"정보가 올바르지 않습니다");
dig.value=''; 
dig.focus();
return;
}
}
return true;
}

 

//************ 학과 선택 시작 ************//
mess_curclm=new Array(3);
mess_curclm[0]="\
<SELECT name=univ_dept2 >\
<option value='의예과' >의예과</option>\
<option value='약학과' >약학과</option>\
<option value='한의학과' >한의학과</option>\
<option value='간호학과' >간호학과</option>\
<option value='수학과' >수학과</option>\
<option value='물리학과' >물리학과</option>\
<option value='과학관련학' >과학관련학</option>\
<option value='과학교육과' >과학교육과</option>\
<option value='생명공학과' >생명공학과</option>\
<option value='화학과' >화학과</option>\
<option value='화공학과' >화공학과</option>\
<option value='전자공학과' >전자공학과</option>\
<option value='전기공학과' >전기공학과</option>\
<option value='건축공학과' >건축공학과</option>\
<option value='산업공학과' >산업공학과</option>\
<option value='전산학과' >전산학과</option>\
<option value='컴퓨터학과' >컴퓨터학과</option>\
<option value='디자인학과' >디자인학과</option>\
<option value='원자력학과' >원자력학과</option>\
<option value='분자학과' >분자학과</option>\
<option value='재료공학과' >재료공학과</option>\
<option value='해양학과' >해양학과</option>\
<option value='기계공학과' >기계공학과</option>\
<option value='자원공학과' >자원공학과</option>\
<option value='환경학과' >환경학과</option>\
<option value='도시공학과' >도시공학과</option>\
<option value='소비자학과' >소비자학과</option>\
<option value='의류학과' >의류학과</option>\
<option value='가정학과' >가정학과</option>\
<option value='생물학과' >생물학과</option>\
<option value='수의학과' >수의학과</option>\
<option value='조경학과' >조경학과</option>\
<option value='식품영양학과' >식품영양학과</option>\
<option value='생물' >생물</option>\
<option value='지구과학' >지구과학</option>\
<option value='지리' >지리</option>\
</SELECT>\
";

mess_curclm[1] = "\
<SELECT name=univ_dept2 >\
<option value='영문학과' >영문학과</option>\
<option value='영어교육과' >영어교육과</option>\
<option value='국문과' >국문과</option>\
<option value='국어교육과' >국어교육과</option>\
<option value='중문과' >중문과</option>\
<option value='독문과' >독문과</option>\
<option value='일문과' >일문과</option>\
<option value='불문과' >불문과</option>\
<option value='경영학과' >경영학과</option>\
<option value='경제학과' >경제학과</option>\
<option value='무역학과' >무역학과</option>\
<option value='법학과' >법학과</option>\
<option value='법과사회' >법과사회</option>\
<option value='정치학' >정치학</option>\
<option value='외교학' >외교학</option>\
<option value='정경학' >정경학</option>\
<option value='정치' >정치</option>\
<option value='역사학' >역사학</option>\
<option value='동양사' >동양사</option>\
<option value='서양사' >서양사</option>\
<option value='국사' >국사</option>\
<option value='사회학' >사회학</option>\
<option value='사회문화' >사회문화</option>\
<option value='신문방송학' >신문방송학</option>\
<option value='언론학' >언론학</option>\
<option value='인문학' >인문학</option>\
<option value='철학' >철학</option>\
<option value='서양어문' >서양어문</option>\
<option value='행정학' >행정학</option>\
<option value='언어학' >언어학</option>\
<option value='심리학' >심리학</option>\
<option value='교육학' >교육학</option>\
<option value='신학' >신학</option>\
<option value='사회복지' >사회복지</option>\
<option value='한문' >한문</option>\
<option value='윤리' >윤리</option>\
</SELECT>\
";

mess_curclm[2] = "\
<SELECT name=univ_dept2 >\
<option value='연극학과' >연극학과</option>\
<option value='영화학과' >영화학과</option>\
<option value='만화학과' >만화학과</option>\
<option value='음악관련학과' >음악관련학과</option>\
<option value='피아노' >피아노</option>\
<option value='성악' >성악</option>\
<option value='바이올린' >바이올린</option>\
<option value='현악' >현악</option>\
<option value='기악' >기악</option>\
<option value='국악' >국악</option>\
<option value='작곡' >작곡</option>\
<option value='미술관련학' >미술관련학</option>\
<option value='조소' >조소</option>\
<option value='공예' >공예</option>\
<option value='회화' >회화</option>\
<option value='동서양화' >동서양화</option>\
<option value='동양화' >동양화</option>\
</SELECT>\
";

 

// ####################################################################################################
// HTML 사용 예제..

 

<SELECT class=inputBorder onchange="change_curclm('document',this,0);" name=univ_dept1> 
<OPTION value=이과/공과계열 selected>이과/공과계열</OPTION> 
<OPTION value=인문계열>인문계열</OPTION> 
<OPTION value=예능계열>예능계열</OPTION>
</SELECT>
<DIV id=div_curclm></DIV>

// ####################################################################################################
// ####################################################################################################

 

function change_curclm(targ,selObj,restore) {

if(selObj.options[selObj.selectedIndex].value=='이과/공과계열'){
if(document.layers){
document.layers["div_curclm"].innerHTML=mess_curclm[0];
}else if(document.all) document.all["div_curclm"].innerHTML = mess_curclm[0];
}
else if(selObj.options[selObj.selectedIndex].value=='인문계열'){
if(document.layers){
document.layers["div_curclm"].innerHTML=mess_curclm[1];
} else if(document.all) document.all["div_curclm"].innerHTML = mess_curclm[1];
}
else if(selObj.options[selObj.selectedIndex].value=='예능계열'){
if(document.layers){
document.layers["div_curclm"].innerHTML=mess_curclm[2];
} else if(document.all) document.all["div_curclm"].innerHTML = mess_curclm[2];
}
//************ 학과 선택 끝 ************//

//************ 학년 선택 시작 ************//
mess_sgrade=new Array(3);
mess_sgrade[0]="";

mess_sgrade[1] = "\
<SELECT name=hope_grade >\
<option value='A1학년' >1학년</option>\
<option value='A2학년' >2학년</option>\
<option value='A3학년' >3학년</option>\
<option value='A4학년' >4학년</option>\
<option value='A5학년' >5학년</option>\
<option value='A6학년' >6학년</option>\
</SELECT>\
";

mess_sgrade[2] = "\
<SELECT name=hope_grade >\
<option value='B1학년' >1학년</option>\
<option value='B2학년' >2학년</option>\
<option value='B3학년' >3학년</option>\
</SELECT>\
";

 

 

 

function change_sgrade(targ,selObj,restore) {

if(selObj.options[selObj.selectedIndex].value=='상관없음'){
if(document.layers){
document.layers["div_stu_grade"].innerHTML=mess_sgrade[0];
}else if(document.all) document.all["div_stu_grade"].innerHTML = mess_sgrade[0];
}
else if(selObj.options[selObj.selectedIndex].value=='초등학생'){
if(document.layers){
document.layers["div_stu_grade"].innerHTML=mess_sgrade[1];
} else if(document.all) document.all["div_stu_grade"].innerHTML = mess_sgrade[1];
}
else if(selObj.options[selObj.selectedIndex].value=='중학생' || selObj.options[selObj.selectedIndex].value=='고등학생'){
if(document.layers){
document.layers["div_stu_grade"].innerHTML=mess_sgrade[2];
} else if(document.all) document.all["div_stu_grade"].innerHTML = mess_sgrade[2];
else if(selObj.options[selObj.selectedIndex].value=='재수생' || selObj.options[selObj.selectedIndex].value=='일반인' || selObj.options[selObj.selectedIndex].value=='중,고등학생' || selObj.options[selObj.selectedIndex].value=='초,중,고등학생'){
if(document.layers){
document.layers["div_stu_grade"].innerHTML=mess_sgrade[0];
} else if(document.all) document.all["div_stu_grade"].innerHTML = mess_sgrade[0];
}
//************ 학년 선택 끝 ************//
 

//************ 희망지역 선택 시작 ************//
mess_area=new Array(16);

mess_area[0]="\
<SELECT name=kawe_area1_1 >\
<option value='전지역' >전지역</option>\
<option value='강남구' >강남구</option>\
<option value='강동구' >강동구</option>\
<option value='강북구' >강북구</option>\
<option value='강서구' >강서구</option>\
<option value='관악구' >관악구</option>\
<option value='광진구' >광진구</option>\
<option value='구로구' >구로구</option>\
<option value='금천구' >금천구</option>\
<option value='노원구' >노원구</option>\
<option value='도봉구' >도봉구</option>\
<option value='동대문구' >동대문구</option>\
<option value='동작구' >동작구</option>\
<option value='마포구' >마포구</option>\
<option value='서대문구' >서대문구</option>\
<option value='서초구' >서초구</option>\
<option value='성동구' >성동구</option>\
<option value='성북구' >성북구</option>\
<option value='송파구' >송파구</option>\
<option value='양천구' >양천구</option>\
<option value='영등포구' >영등포구</option>\
<option value='용산구' >용산구</option>\
<option value='은평구' >은평구</option>\
<option value='종로구' >종로구</option>\
<option value='중구' >중구</option>\
<option value='중랑구' >중랑구</option>\
</SELECT>\
";

mess_area[1] = "\
<SELECT name=kawe_area1_1 >\
<option value='전지역' >전지역</option>\
<option value='강서구' >강서구</option>\
<option value='금정구' >금정구</option>\
<option value='기장군' >기장군</option>\
<option value='남구' >남구</option>\
<option value='동구' >동구</option>\
<option value='동래구' >동래구</option>\
<option value='부산진구' >부산진구</option>\
<option value='북구' >북구</option>\
<option value='사상구' >사상구</option>\
<option value='사하구' >사하구</option>\
<option value='서구' >서구</option>\
<option value='수영구' >수영구</option>\
<option value='연제구' >연제구</option>\
<option value='영도구' >영도구</option>\
<option value='중구' >중구</option>\
<option value='해운대구' >해운대구</option>\
</SELECT>\
";

 

//************ 희망지역 선택 시작 ************//
mess_area01=new Array(16);

mess_area01[0]="\
<SELECT name=kawe_area2_1 >\
<option value='전지역' >전지역</option>\
<option value='강남구' >강남구</option>\
<option value='강동구' >강동구</option>\
<option value='강북구' >강북구</option>\
<option value='강서구' >강서구</option>\
<option value='관악구' >관악구</option>\
<option value='광진구' >광진구</option>\
<option value='구로구' >구로구</option>\
<option value='금천구' >금천구</option>\
<option value='노원구' >노원구</option>\
<option value='도봉구' >도봉구</option>\
<option value='동대문구' >동대문구</option>\
<option value='동작구' >동작구</option>\
<option value='마포구' >마포구</option>\
<option value='서대문구' >서대문구</option>\
<option value='서초구' >서초구</option>\
<option value='성동구' >성동구</option>\
<option value='성북구' >성북구</option>\
<option value='송파구' >송파구</option>\
<option value='양천구' >양천구</option>\
<option value='영등포구' >영등포구</option>\
<option value='용산구' >용산구</option>\
<option value='은평구' >은평구</option>\
<option value='종로구' >종로구</option>\
<option value='중구' >중구</option>\
<option value='중랑구' >중랑구</option>\
</SELECT>\
";
 

 

 

function change_area_reg(targ,selObj,restore) {
if(selObj.options[selObj.selectedIndex].value=='서울특별시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[0];
}else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[0];
}
else if(selObj.options[selObj.selectedIndex].value=='부산광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[1];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[1];
}
else if(selObj.options[selObj.selectedIndex].value=='대전광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[2];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[2];
}
else if(selObj.options[selObj.selectedIndex].value=='대구광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[3];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[3];
}
else if(selObj.options[selObj.selectedIndex].value=='광주광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[4];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[4];
}
else if(selObj.options[selObj.selectedIndex].value=='경상북도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[5];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[5];
}
else if(selObj.options[selObj.selectedIndex].value=='경상남도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[6];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[6];
}
else if(selObj.options[selObj.selectedIndex].value=='경기도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[7];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[7];
}
else if(selObj.options[selObj.selectedIndex].value=='충청북도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[8];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[8];
}
else if(selObj.options[selObj.selectedIndex].value=='충청남도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[9];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[9];
}
else if(selObj.options[selObj.selectedIndex].value=='제주도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[10];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[10];
}
else if(selObj.options[selObj.selectedIndex].value=='전라북도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[11];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[11];
}
else if(selObj.options[selObj.selectedIndex].value=='전라남도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[12];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[12];
}
else if(selObj.options[selObj.selectedIndex].value=='인천광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[13];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[13];
}
else if(selObj.options[selObj.selectedIndex].value=='울산광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[14];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[14];
}
else if(selObj.options[selObj.selectedIndex].value=='강원도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[15];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[15];
}



// HTML 사용예제..

<SELECT class=inputBorder onchange="change_area_reg01('document',this,0)" name=kawe_area2>
<OPTION value=서울특별시 
selected>서울특별시</OPTION> <OPTION 
value=부산광역시>부산광역시</OPTION> <OPTION 
value=대전광역시>대전광역시</OPTION> <OPTION 
value=대구광역시>대구광역시</OPTION> <OPTION 
value=광주광역시>광주광역시</OPTION> <OPTION 
value=인천광역시>인천광역시</OPTION> <OPTION 
value=울산광역시>울산광역시</OPTION> <OPTION 
value=강원도>강원도</OPTION> <OPTION 
value=경기도>경기도</OPTION> <OPTION 
value=충청북도>충청북도</OPTION> <OPTION 
value=충청남도>충청남도</OPTION> <OPTION 
value=경상북도>경상북도</OPTION> <OPTION 
value=경상남도>경상남도</OPTION> <OPTION 
value=전라북도>전라북도</OPTION> <OPTION 
value=전라남도>전라남도</OPTION> <OPTION 
value=제주도>제주도</OPTION></SELECT></TD>

<DIV id=div_area_reg_sub01></DIV>

 

 

function change_area_reg01(targ,selObj,restore) {
if(selObj.options[selObj.selectedIndex].value=='서울특별시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[0];
}else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[0];
}
else if(selObj.options[selObj.selectedIndex].value=='부산광역시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[1];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[1];
}
else if(selObj.options[selObj.selectedIndex].value=='대전광역시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[2];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[2];
}
else if(selObj.options[selObj.selectedIndex].value=='대구광역시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[3];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[3];
}
else if(selObj.options[selObj.selectedIndex].value=='광주광역시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[4];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[4];
}
else if(selObj.options[selObj.selectedIndex].value=='경상북도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[5];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[5];
}
else if(selObj.options[selObj.selectedIndex].value=='경상남도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[6];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[6];
}
else if(selObj.options[selObj.selectedIndex].value=='경기도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[7];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[7];
}
else if(selObj.options[selObj.selectedIndex].value=='충청북도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[8];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[8];
}
else if(selObj.options[selObj.selectedIndex].value=='충청남도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[9];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[9];
}
else if(selObj.options[selObj.selectedIndex].value=='제주도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[10];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[10];
}
else if(selObj.options[selObj.selectedIndex].value=='전라북도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[11];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[11];
}
else if(selObj.options[selObj.selectedIndex].value=='전라남도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[12];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[12];
}
else if(selObj.options[selObj.selectedIndex].value=='인천광역시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[13];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[13];
}
else if(selObj.options[selObj.selectedIndex].value=='울산광역시'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[14];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[14];
}
else if(selObj.options[selObj.selectedIndex].value=='강원도'){
if(document.layers){
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[15];
} else if(document.all) document.all["div_area_reg_sub01"].innerHTML = mess_area01[15];
}
//************ 희망지역 선택 끝 ************//

// InnerHTML 초기 셋팅
function modifySelBox() {
var fwrite = document.frm_reg;

if(fwrite.univ_dept1.value=='이과/공과계열'){
if(document.layers){
document.layers["div_univ_dept1"].innerHTML=mess_univ_dept1[0];
}else if(document.all) document.all["div_univ_dept1"].innerHTML = mess_univ_dept1[0];
}
else if(fwrite.univ_dept1.value=='인문계열'){
if(document.layers){
document.layers["div_univ_dept1"].innerHTML=mess_univ_dept1[1];
} else if(document.all) document.all["div_univ_dept1"].innerHTML = mess_univ_dept1[1];
}
else if(fwrite.univ_dept1.value=='예능계열'){
if(document.layers){
document.layers["div_univ_dept1"].innerHTML=mess_univ_dept1[2];
} else if(document.all) document.all["div_univ_dept1"].innerHTML = mess_univ_dept1[2];
}

if(fwrite.hope_zone.value=='서울특별시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[0];
}else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[0];
}
else if(fwrite.hope_zone.value=='부산광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[1];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[1];
}
else if(fwrite.hope_zone.value=='대전광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[2];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[2];
}
else if(fwrite.hope_zone.value=='대구광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[3];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[3];
}
else if(fwrite.hope_zone.value=='광주광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[4];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[4];
}
else if(fwrite.hope_zone.value=='경상북도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[5];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[5];
}
else if(fwrite.hope_zone.value=='경상남도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[6];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[6];
}
else if(fwrite.hope_zone.value=='경기도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[7];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[7];
}
else if(fwrite.hope_zone.value=='충청북도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[8];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[8];
}
else if(fwrite.hope_zone.value=='충청남도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[9];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[9];
}
else if(fwrite.hope_zone.value=='제주도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[10];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[10];
}
else if(fwrite.hope_zone.value=='전라북도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[11];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[11];
}
else if(fwrite.hope_zone.value=='전라남도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[12];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[12];
}
else if(fwrite.hope_zone.value=='인천광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[13];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[13];
}
else if(fwrite.hope_zone.value=='울산광역시'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[14];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[14];
}
else if(fwrite.hope_zone.value=='강원도'){
if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[15];
} else if(document.all) document.all["div_area_reg_sub"].innerHTML = mess_area[15];
}

// InnerHTML 초기 셋팅
function inteSelBox() {
if(document.layers){
document.layers["div_curclm"].innerHTML=mess_curclm[0];
}else if(document.all) document.all["div_curclm"].innerHTML = mess_curclm[0];

if(document.layers){
document.layers["div_area_reg_sub"].innerHTML=mess_area[0];
document.layers["div_area_reg_sub01"].innerHTML=mess_area01[0];
}else if(document.all) {
document.all["div_area_reg_sub"].innerHTML = mess_area[0];
document.all["div_area_reg_sub01"].innerHTML = mess_area01[0];
}

}

// radio box , checkbox

html>
<head>
<script language="javascript">

function func_check(){
var mystr="";
if(document.myform.Music.checked){
mystr+="음악감상";
}

if(document.myform.Sleep.checked){
mystr+=" 잠자기";
}

if(document.myform.Com.checked){
mystr+=" 컴퓨터";
}

if (mystr==""){
mystr = "취미가 없습니다";
}else{
mystr +="를 선택하셨습니다";
}
alert(mystr);
}

function func_radio(){
var SeasonStr ="";
for(i=0;i< document.myform1.season.length;i++){
if (document.myform1.season[i].checked) SeasonStr = document.myform1.season[i].value;
}

if(SeasonStr=="Spring") {
alert("봄을 선택하셨습니다");
}else if(SeasonStr=="Summer"){
alert("여름을 선택하셨습니다");
}else if(SeasonStr=="Fall"){
alert("가을을 선택하셨습니다");
}else if(SeasonStr=="Winter"){
alert("겨울을 선택하셨습니다");
}else{ 
alert("좋아하는 계절이 없나요? 다시선택하세요!");
}
}
function func_radio2(){

if(document.myform1.season[0].checked){
alert("봄을 선택하셨습니다");
}else if(document.myform1.season[1].checked){
alert("여름을 선택하셨습니다");
}else if(document.myform1.season[2].checked){
alert("가을을 선택하셨습니다");
}else if(document.myform1.season[3].checked){
alert("겨울을 선택하셨습니다");
}else{
alert("좋아하는 계절이 없나요? 다시선택하세요!");
}
}
</script>
</head>
<body>
<form method=post action="" name="myform">
취미 : <input type="checkbox" name="Music" value="음악감상" checked>음악감상
<input type="checkbox" name="Sleep" value="잠자기" >잠
<input type="checkbox" name="Com" value="컴퓨터">컴퓨터
<br>
<input type="button" value="확인" onClick="func_check()">
</form>
<br><br>

좋아하는 계절 : 
<form method=post action="" name="myform1">
<input type="radio" name="season" value="Spring" checked>봄
<input type="radio" name="season" value="Summer">여름
<input type="radio" name="season" value="Fall">가을
<input type="radio" name="season" value="Winter">겨울
<br>
<input type="button" value="확인" onClick="func_radio2()">
</form>
</body>
</html>

댓글 없음:

댓글 쓰기