본문 바로가기

프로그래밍/자바스크립트

자바스크립트 기타

  

이전페이지로 돌아가기(텍스트박스 내용들 유지됨)
   <script type="text/javascript">
    alert("메세지");
    history.back(-1); // 이전페이지로 돌아가기(텍스트박스 내용들 유지됨)
   </script>

///////////////////////////////////////////////////////////////////

 

  익스플로러 창 띄우기('_self')- 현재창에서
        ('_blank')- 새창에서

  <script type="text/javascript">
   alert("메세지");
   window.open('http://www.xxxxx.com/xxxx.jsp','_self'); // 주소,형태
  </script>

 

//////////////////////////////////////////////////////////////////////

폼 아이디 값 얻기

var form = document.getElementById("default_form");

/////////////////////////////////////////////////////////////////////

체크박스 클릭시 나타나기 
% <tr>에 아이디 값을 줘서 자바스크립트로 받아서 나타내기


function ShowDisInput(obj){
    ShowDisRow(obj.checked);
   }

   function ShowDisInput_file(obj){
    var disFileCheckLater = document.getElementById("dis_file_check_later");
    disFileCheckLater.checked = false;
    ShowDisRow_file(obj.checked);
 
   }

   function ShowDisInput_file_later(obj){
    var disFileCheck = document.getElementById("dis_file_check");
    disFileCheck.checked = false;
    ShowDisRow_file_later(obj.checked);
   }

   function ShowDisRow(show){
    
    var row_dis_grade = document.getElementById("row_dis_grade");
    var row_dis_file_check = document.getElementById("row_dis_file_check");
    var row_dis_file = document.getElementById("row_dis_file");
    var row_dis_file_later = document.getElementById("row_dis_file_later");
    
    
    if(show){
     row_dis_grade.style.display = "block";
     row_dis_file_check.style.display = "block";
     row_dis_file.style.display = "none";
     row_dis_file_later.style.display = "none";
     
    }
    else {
     row_dis_grade.style.display = "none";
     row_dis_file_check.style.display = "none";
     row_dis_file.style.display = "none";
     row_dis_file_later.style.display = "none";
     

    }
   }

   function ShowDisRow_file(show){    
    
    var row_dis_file = document.getElementById("row_dis_file");
    var row_dis_file_later = document.getElementById("row_dis_file_later");
    
   
    if(show){ 
     row_dis_file.style.display = "block";
     row_dis_file_later.style.display = "none";
     
    }
    else {
     row_dis_file.style.display = "none";
     row_dis_file_later.style.display = "none";
    
    }
   }

   function ShowDisRow_file_later(show){    
   
    var row_dis_file = document.getElementById("row_dis_file");
    var row_dis_file_later = document.getElementById("row_dis_file_later");
    
   
    if(show){ 
     row_dis_file.style.display = "none";
     row_dis_file_later.style.display = "block";
     
    }
    else {
     row_dis_file.style.display = "none";
     row_dis_file_later.style.display = "none";
     
    }
   }

 

------화면소스 ---

<colgroup>
        <col width="120px" />
        <col width="550px" />
       </colgroup>
       <tbody>
        <tr>
         <th scope="row"><label for="dis_check">시각장애인<br/>전용 서비스</label></th>
         <td>
          <input type="checkbox" id="dis_check" name="disabled_yn" value="Y" onClick="ShowDisInput(this);">
          <label for="dis_check">신청</label>
         </td>
        </tr>
        <!--
        <tr id="row_dis_type">
         <th scope="row"><label for="dis_type">장애구분</label> <span class="c_ff5907" title="필수항목">*</span></th>
         <td>
          <select title="장애구분선택" id="dis_type" name="dis_type">
           <option >선택</option>
           <option value="0">시각장애</option>
           <option value="1">청각장애</option>
          </select>
         </td>
        </tr>
        -->
        <tr id="row_dis_grade">
         <th scope="row"><label for="dis_grade">장애등급</label> <span class="c_ff5907" title="필수항목">*</span></th>
         <td>
          <select title="장애등급선택" id="dis_grade" name="dis_grade">
           <option >선택</option>
           <option value="1">&nbsp;1급장애&nbsp;</option>
           <option value="2">&nbsp;2급장애&nbsp;</option>
           <option value="3">&nbsp;3급장애&nbsp;</option>
          </select>
         </td>
        </tr>

 

        <tr id="row_dis_file_check">
         <th scope="row"><label for="dis_file_check">파일첨부 선택</label><span class="c_ff5907" title="필수항목">*</span></th>
         <td>
          <input type="checkbox" id="dis_file_check" name="dis_file_check" value="Y" onClick="ShowDisInput_file(this);">
          <label for="dis_file_check">지금하기</label>
          <input type="checkbox" id="dis_file_check_later" name="dis_file_check_later" value="N" onClick="ShowDisInput_file_later(this);">
          <label for="dis_file_check_later">나중에 하기</label>
         </td>
        </tr>

        <tr id="row_dis_file">
         <th scope="row"><label for="dis_file">파일첨부</label> <span class="c_ff5907" title="필수항목">*</span></th>
         <td>
          <p class="txt">
           장애인을 증명할 수 있는 파일을 첨부해 주세요.<br />
           첨부파일은 이미지 파일과 PDF, HWP, JPEG, tiff만 가능합니다.
          </p>
          <div class="mgt_5"><input type="file" id="dis_file" name="dis_file" title="장애인 증명 파일 선택" class="file" size="46" /></div>
         </td>
        </tr>
        <tr id="row_dis_file_later">
         <th scope="row" rowspan="2"><label for="dis_file_later">선택하세요</label> <span class="c_ff5907" title="필수항목">*</span></th>
         <td rowspan="2">
          <select title="메일,팩스 선택하기" id="dis_file_later" name="dis_file_later">
           <option >선택</option>
           <option value="mail">&nbsp;메일&nbsp;</option>
           <option value="fax">&nbsp;Fax&nbsp;</option>
          </select>
         <!--
          <input type="checkbox" name="later_mail_fax" title="나중에 메일 보내기" value="Mail"/> 메일<br/>
          <input type="checkbox" name="later_mail_fax" title="나중에 팩스 보내기" value="Fax"/> 팩스

          -->
         </td>
        </tr>
       

       </tbody>

 

/////////////////////////////////////////////////////////////////////////////

페이지 로딩시 자동으로 실행시키는 자바스크립트
window.onload=
 예) /* 

window.onload=function Show_menu(obj){


    var row_dis_grade = document.getElementById("row_dis_grade");
    var row_dis_file_check = document.getElementById("row_dis_file_check");
    var row_dis_file = document.getElementById("row_dis_file");
    var row_dis_file_later = document.getElementById("row_dis_file_later");
    
    row_dis_grade.style.display = "none";
       row_dis_file_check.style.display = "none";
       row_dis_file.style.display = "none";
       row_dis_file_later.style.display = "none";


   }
*/