190618_Day47 <JavaScript 시작>

form 태그 역할

  1. form내의 입력데이터를 action속성에 명시한 URL 페이지에게 전달(이동)

    보통 URL 페이지에는 서버페이지가 표시가 됨. (.jsp .php .asp .do 등)

  2. 페이지 이동 < a > 와 더불어.

    • < a > 는 단순 이동

      <a href="../0617/hello.html">
    • < form action > 은 데이터 전송과 함께 페이지 이동

      <form action = "../0617/hello.html">

input

  • 기본 type 은 text

    <input>
    • password 와 같은 type을 줄 수 있다.

      <input type = "password">
  • value 값에는 기본 값(초기값) 설정 할 수 있다.

    <input value = "기본아이디">
  • size속성 통해 길이 조정 가능

    <input size = "1">
  • 그런데 글자 size보다 더 입력되네? => maxlength 통해 조절 가능

    <input size = "1" maxlength = "1">
  • type = checkbox 로 다중선택 가능

    <input type = "checkbox"> 사과
    <input type = "checkbox" checked> 딸기
    <input type = "checkbox"> 바나나
  • radio와 name 을 통해 택1 선택 가능

    <input type = "radio" name = "room"> 1강의실
    <input type = "radio" name = "room"> 2강의실
    <input type = "radio" name = "room"> 3강의실
    <input type = "radio" name = "room"> 4강의실
  • form, name 값과 submit을 통해 입력한 값을 전송 할 수 있다.

    <input type = "submit" name ="button1" value = "버튼3(type = submit)">
  • hidden을 통해 보이지 않게 데이터를 전달 할 수 있다. (추후 사용용도 배움)

    <input type = "hidden" value = "전송"> 
  • type file로 파일 업로드 가능!

    <input type = "file">
  • method 은 get이 dafault , post옵션을 통해 전송된 값 안보이게 할 수 있다. (추후 배움)

  • enctype (추후 배움)

  • 콤보박스는 input태그를 사용하는것이 아니라 select 태그를 사용함!

        운동 : <select multiple>
                <option>야구</option>
                <option selected>축구</option>
                <option>농구</option>
                <option>배구</option>
            </select>
  • select multiple 을 사용하면 아이템이 펼처진 상태에서 보여짐

    <select multiple>
  • textarea 통해 선택한 크기의 텍스트 상자 사용 가능

    <textarea rows="5" cols="10" >기본내용은 여기에</textarea>
    • 단 value 사용 불가
  • Button 4종 비교 정리

    1. 아무반응없는 눌려지는 버튼 (JavaScript를 통해 기능정의 가능)
    <input type = "button" value = "버튼1(type = button)">
  1. button태그의 기본 type 속성의 값은 submit입니다

        <button type = 'submit'> 기본값 
        즉, form태그 안에 사용하면 <inputj type = 'submit'>과  같은 기능을 갖음
        만약, submit이 아닌 다른 기능을 구현하고 싶다면 명시적인 type속성을 정의해야 함
    <button type = "submit"> 버튼2 ( button태그 ) </button>
  2. form태그내의 submit버튼의 경우 action속성의 URL이동

    <input type = "submit" value = "버튼3(type = submit)">
  3. form태그내의 reset버튼의 경우 폼 내의 데이터를 초기화 하는 기능

    <input type = "reset" value = "버튼4(type = reset)">
  • 만약, < input > 태그를 브라우저화면 보이기만 하는것이 목적이라면 굳이 < form > 태그 안에 정의할 필요 없음.
  • < input > 태그를 < form> 태그안에 정의하는 이유는 폼 단위로 데이터를 특정 페이지에게 전달하기 위함
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>폼태그 테스트 (input 태그)</title>
</head>
<!-- form_test.html -->
<body>
    <h3>폼태그 테스트 (input 태그)</h3>
    <hr>

    <h4>단순 페이지 이동</h4>
    <a href="../0617/hello.html"> hello.html 문서로 이동!  </a>

    <hr>
    <h4>정보와 함께 페이지 이동 (form)</h4>
    <form action = "../0617/hello.html" name =""
            method = "post" enctype="application/x-www-form-urlencoded"> hello.html 문서로 이동! 

    <br>

    기본 input : <input> <br> <!-- 기본type은 text -->
     아 이 디 &nbsp;: <input type = "text" value = "기본아이디" size = "10" name = "id"> <br>
    비밀번호 : <input type = "password" name = "password"> <br>
    주민번호 : <input type="text" size = "6" maxlength="6" name = "ssn1"> 
            - 
            <input type = "password" size = "7" maxlength="7" name = "ssn2"> <br>
    좋아하는 과일 : <input type = "checkbox"> 사과
               <input type = "checkbox" checked> 딸기
               <input type = "checkbox"> 바나나
               <br>
    나의    강의실 : <input type = "radio" name = "room"> 1강의실
               <input type = "radio" name = "room"> 2강의실
               <input type = "radio" name = "room"> 3강의실
               <input type = "radio" name = "room"> 4강의실
                <br>

    파일  업로드 : <input type = "file">
    <br>
    운동 : <select multiple>
            <option>야구</option>
            <option selected>축구</option>
            <option>농구</option>
            <option>배구</option>
        </select>    

    <br>
    비고 : <textarea rows="5" cols="10" >기본내용은 여기에</textarea>
    <br>
    나보여?         <input type = "hidden" value = "전송"> 
    <br>
    <input type = "button" value = "버튼1(type = button)">
    <!-- 아무반응없는 눌려지는 버튼 (JavaScript를 통해 기능정의 가능) -->

    <button type = "submit"> 버튼2 ( button태그 ) </button>
    <!-- button태그의 기본 type 속성의 값은 submit입니다
        <button type = 'submit'> 기본값 
        즉, form태그 안에 사용하면 <inputj type = 'submit'>과  같은 기능을 갖음
        만약, submit이 아닌 다른 기능을 구현하고 싶다면 명시적인 type속성을 정의해야 함
    -->

    <input type = "submit" value = "버튼3(type = submit)">
    <!-- form태그내의 submit버튼의 경우 action속성의 URL이동 -->

    <input type = "reset" value = "버튼4(type = reset)">
    <!-- form태그내의 reset버튼의 경우 폼 내의 데이터를 초기화 하는 기능 -->

    </form>



</body>
</html>

미션 회원가입폼을 브라우저에 출력하시오.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>회원가입폼</title>
</head>
<body>
    <center>
    <h3 align="left">회원 가입</h3>
    <hr>
    <form action="" name="" method="get" >

        <table align="center" cellpadding="5">
            <tr>
                <td>아이디 :</td>
                <td><input type="text" size="10" name="id"></td>
                <td><button>아이디 중복확인</button></td>
            </tr>
            <tr>
                <td>비밀번호 :</td>
                <td><input type="password" size="10" name="pass"></td>
            </tr>
            <tr>
                <td>비번확인 :</td>
                <td><input type="password" size="10" name="pcheck"></td>
            </tr>
            <tr>
                <td>이름 :</td>
                <td><input type="text" size="5" maxlength="5" name="name">
                </td>
            </tr>
            <tr>
                <td>주민번호 :</td>
                <td><input type="text" size="6" maxlength="6" name="ssn1">
                    - <input type="password" size="7" maxlength="7" name="ssn2">
                </td>
            </tr>
            <tr>
                <td>전화번호 :</td>
                <td><input type="text" size="3" maxlength="3" name="pnum1">
                    - <input type="text" size="4" maxlength="3" name="pnum2"> -
                    <input type="text" size="4" maxlength="3" name="num3"></td>
            </tr>
            <tr>
                <td>주소 :</td>
                <td><input type="text" size="30" name="addr"></td>
            </tr>
            <tr>
                <td>직업 :</td>
                <td><select>
                        <option>학생</option>
                        <option>직장인</option>
                        <option>자영업</option>
                        <option>강아지</option>
                </select></td>
            </tr>
            <tr>
                <td colspan="3" align="center">
                    <button type="submit" value="등록">등록</button>
                    <button type="reset" value="취소">취소</button>
                </td>
            </tr>
        </table>



    </form>
    </center>
</body>
</html>
  • form 에 < form > 만 입력하고 옵션 주지 않아도 기본적으로 action에 기본값이 들어가기 때문에 submit이 되는 것.
  • post옵션은 주겠다 라는 것! 데이터를 주고 html을 다시 받아오겠다. 주는 의미가 강함.
  • < input > 태그의 속성
    • readonly 읽기 전용 ( 쓰기 금지 ) : 자바의 setEditable(false)
    • disabled 비활성화 : 자바의 setEnable(false)

base

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<!-- 
    base.html(레이아웃을 정하는 Html문서, FrameSet정의)
    주의 body태그 사용x, body태그 자리에 frameset태그를 정의
 -->
    <frameset rows = " 20%, *">
        <frame src = "header.html" name = "header">
        <frameset cols = "20%,*">
            <frame src = "menu.html" name = "menu"> 
            <frame src = "body.html" name = "body"> 
            </frameset>
            <!-- frame태그의 속성 name은 각 레이아웃의 위치 식별을 하는 용도로 사용 -->

    </frameset> 
<body>

</body>
</html>

body

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<!-- body.html -->
<body>
    기본 바디
</body>
</html>

header

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<!-- header.html -->
<body bgcolor="lightgreen">
    <center>
        <h2> FrameSet 헤더 </h2>
    </center>
</body>
</html>

menu

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<!-- menu.html -->
<body bgcolor="brown">
    <h3> 메뉴 </h3>
    <ul><!--  unordered list -->
        <li>기본</li> <!-- list item -->
        <li><a href="join_form.html"  target ="body" >회원가입</a></li>
        <li><a href= "../0617/tag_test.html" target = "body">태그테스트</a></li>
        <li><a href= "http://playdata.io" target = "body">플레이데이터</a></li>

    </ul>

</body>
</html>

1560838336081


< 자바스크립트 >

  • 웹브라우저에서 실행되는 프로그램
  • HTML문서내에서 실행(html에 종속적이다, 브라우저에서 실행된다!)
  • HTML문서( 정적페이지 ) = > JavaSctipt적용(동적페이지)
  • HTML 문서를 통해 입력된 데이터를 얻어오고 데이터에 대한 유효성 검사를 할 때 사용
  • HTML문서에 대한 조작 ( 태그, 속성, 스타일)
  • 결론) 자바스크립트 왜(어디서) 사용하는가?
    • 문서 조작 (태그와 속성)
      • 조작에 필요한 데이터가 외부에 존재한다면(현재 HTML 없을 시) Ajax를 사용!!
    • 유효성 검사 (서버에게 데이터를 보내기 전에 검사)

<<JavaScript와 java 비교>>

  1. JavaScript : 클라이언트(사용자, 브라우저) 스크립트 : 브라우저에서 실행

    JSP(Java) : 서버 스크립트 : JVM에서 실행!

  2. JavaScript의 위치

    • HTML문서내에 포함되어서 실행

    • HTML문서의 어떤 위치라도 정의하는 것이 가능!

      <html>
          <head>
              <sctipt>
                  프로그램영역!
                  (변수선언, 함수(function) 정의 (절대 실행은 안됨, 호출 전까지))
              </sctipt>
          </head>
          <body>
                 <script>
                  프로그램영역
                  (함수 호출)
              </script>
          </body>
      </html>
      
  3. 자료형을 선언, 정의하지 않는다!! ★

    자바의 경우

    String name = "홍길동";
            name = "길라임";
            name = 3000; (X) 에러발생 

    자바스크립트의 경우

    String name = "홍길동"; (X) 에러발생 
    name = "홍길동"; (O) 자료형 선언 않고 사용!
        ////////
    var su; ---> 변수선언
    su = 2000; ---> number타입!
    su = "김주원" ---> String타입 // 대입되는 데이터에 따라 자료형이 변환됨
    su = true; ---> boolean타입
    su = new Data(); ---> Date타입

'클라우드 기반 웹 개발자 과정 공부 > HTML' 카테고리의 다른 글

190617_DAY46 <HTML>  (0) 2019.06.17

190617_DAY46

<HTML.>

  • 인터넷과 함께 성장한 언어
  • 웹 문서를 만들기 위한 언어
  • HyperText Markup Language
    • HyperText
      • 뛰어넘다 + Text
      • 다른 문서 연결 텍스트
      • 비순차적 텍스트
      • 사용자 선택에 따라 관련 부분으로 이동하는, 조직화 문서
    • Markup
      • 표시하는 것, 구조적으로 하는 것
      • 어디서부터 어디까지인지 표현하는 것

<html>
    <head>
        <!--
        HTML 문서의 정보
        타이틀, 작성자, 검색키워드
        CSS, 자바스크립트 정의
        -->
    </head>
    <body>
        <!--
        브라우저에 보일 텍스트 또는 이미지
        -->
    </body>

</html>
  • 저장확장자 : .html .htm

  • 태그속성 으로 구성
  • 타 언어와의 차이점!
    • 자바는
      • System.out.println( button ) : 변수명
      • System.out.println( " button " ) : String의 의미
    • SQL은
      • select button
      • select ' button ' : charater의 의미
    • HTML은
      • button
      • < button > : Tag의 의미

  1. 태그 ( Tag )

    • < 텍스트 > : 부등호 괄호 <> 안에 텍스트가 들어 갈 때 태그!
    • 종류
      • 시작태그 < button >
      • 끝태그 < /button >
      • 빈태그 <hr / >: < hr >< /hr > >< 사이에 아무것도 , 공백도 없다. 문자 1도 없다 = < hr / >
  2. 엘리먼트 ( Element )

    <table>
        <tr>
            <td> 기묭진 </td>
            <td> 이딘듀 </td>
        </tr>
    </table>
    • table 엘리먼트
      • table 태그가 포함하는 모든 자식요소까지 합친 용어
    • table 태그
      • < table >
      • 속성과 값
  3. 속성 (Atribute)

    • 시작태그 또는 빈태그에 위치

    • 태그 또는 다른 속성과 공백(WhiteSpace)을 구분자로 구분

      • WhiteSpace : 공백, 엔터, 탭
      • 브라우저에서는 WhiteSpace가 스페이스 두번 탭 두번이어도 그냥 공백 하나로!
    • 태그에 추가적인 성질을 정의

    • 형식

      <태그명 속성값 = 속성값> 
      <태그명 속성명 = '속성값'>
          <!-- 작은따옴표, 큰 따옴표는 전혀 차이 없다. -->
      <태그명 속성명 = "속성값">
          <!-- 인용부호 사용 권장 -->
      
      <table border = 1 cellpadding = '5' bgcolor = "yellow">    
      </table>
          <!-- border, cellpadding, bgcolor를 속성이라고 하고 1, 5, yellow를 속성값 이라고 한다 -->

      만약 잘못입력하면, 에러가 발생하지 않고, 표시가 안된다!


www.w3.org

​ 웹 표준 사이트

www.trio.co.kr

​ 수업 테스트 파일

www.w3schools.com

​ 참조사이트


한번 만들어 보자

<html>
    <head>
        <title> 문서 제목 </title>
    </head>


    <!-- 주석! -->

    <body>
        HTML 안녕~!
    </body>
</html>
<html>
    <head>
        <title> 문서 제목 </title>
    </head>


    <!-- 주석! -->

    <body>
        HTML,  <!-- 한개 이상의 space, tab, enter의 조합을 WhiteSpace 브라우저 상에서는 한칸으로 출력됨 -->
         안&nbsp;&nbsp;&nbsp;녕~! <!-- 이거시 스페이스 &nbsp; -->
         <!-- 띄어쓰기 하고 싶다면 -->
         <br>
         br 한번
         <br>
         <br>
         br 두번

        <abc></abc> <!-- 사라졌다...! 브라우저에 등록되지 않은 태그는 무시하고 에러는 발생 안함, 화면 출력 안함 -->

        <h1>h1</h1>
        <h2>h2</h2>
        <h3>h3</h3>
        <h4>h4</h4>
        <h5>h5</h5>
        <h6>h6</h6>
        <h7>h7 은 없는데 어떻게 나올까..? </h7>
        <br>
        <button>                    눌러주세요 </button> <!-- 무조건 한칸 -->


        <font color = "red" size = "7" face="궁서체">기묭진</font>
        <font color = "ff00ff" size = "5" face="굴림">이딘듀</font>
        <font color = "green" size="13" face="impact">Vicky Lee</font>

        <br>
        <b> 강조할땐 b 혹은 strong </b>

        <br>
        <i>눕고 싶으면 i</i>

        <br>
        <u> 밑줄은 u </u>

        <br>
        <del> 태그안에 줄친 글자는 del s strike </del>

        <br>
        5<sup>2(sub)</sup>  log<sub>2(sub)</sub>

        <br>

    </body>
</html>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title> &nbsp; 태그 테스트 </title>
</head>
    <!-- tag_test.html -->

<!-- <body bgcolor = "orange" text="red">  -->
<!-- <body background="ebi.jpg">  -->
<!-- 현재 HTML 문서와 같은 폴더에 이미지 있을 때에는 파일명 명시, 
    현재폴더의 하위폴더에 이미지가 있다면 하위폴더 이름이 -->
<body background="sub/ebi.jpg">
<!--  상위폴더라면 "../ebi.jpg" -->
    <a href = "#bottom" name = "top">아래로 이동</a>

    <center>
        <!-- 브라우저 출력될 내용들
              문단(영역 )태그<p><div>와 영역 태그 <sapn>
         -->
         <!-- p와 div, span을 구별하자 -->
         <font color="black">안녕하세요</font> <p>html p태그(블럭모드)입니다.</p> 
         <!-- 공백줄 생기고 라인 바뀜 -->
         <hr>
         안녕하세요 <div> html div태그(블럭모드)입니다. </div> 
         <!-- 공백줄 없이 라인 바뀜 -->
         <hr>
         안녕하세요 <span> html span태그(라인모드)입니다. </span> 
         <!-- 공백줄, 줄바뀜 없음 , 이 부분만 수정할때 사용하기 위해 씀 -->

         <hr>
         <!-- pre태그 : 블럭모드, 문서상의 공백(space, tab, enter) 유지해서 표현 -->
         <pre>
         동해물과 백두산이
             마르고 닳도록
                 하느님이 보우하사 우리 나라 만세 ? &lt; A &gt;
         </pre>
                  <img src = "ebi3.gif">

         <hr>        
         <a align = "center" href="https://namu.wiki/search/%EB%94%A9%EB%93%80%EA%B0%80%20%ED%91%B8%ED%91%B8">
                  <img alt = "옆방에서 딩듀가..." src = "ebi2.jpg"
                 width = "400"
                 height="300"
                 border="10"
                 title = "딩꼬"></a>

    </center>
      <hr>
      3이 4보다 작다!
      3 &lt; 4
      HTML &amp; 자바스크립트

      <hr size="10" color="red" width="210">
      <hr color="purple" size = 10 width="70%" align = "left">
      <hr color="blue" size = 30% width="50%" align = "center">
      <hr color="red" size = 10 width="70%" align = "right">
      <!-- align 정렬! -->
      <a href="#top">맨 위로 이동!</a>
      <a name = "bottom"></a>
</body>
</html>

DL

  • 정의목록의 데이터, 용어를 설명
  • dt와 dd요소만 자식으로 가능
  • dt는 인라인 dd는 블럭 따라서 dt안에 블럭요소 불가

DD

  • 정의용어의 약자, 용어의 제목

DT

  • 정의 설명, 용어를 설명할때

OL

  • 순서 있는 목록
  • ol요소 안에는 오직 li만 가능 다른 요소를 바로 넣을 수 없고, 넣으려면 li안에 넣어야 한다. li안에 ol중첩 가능
  • 기본은 1부터 시작 start속성 주면 해당 숫자부터

UL

  • 번호없는 목록 ( unordered list )의 태그
  • desc, circle, square

LI

  • 자동 줄 바꿈

TABLE 정렬된 형태로!

  • TR 표의 줄
    • bgcolor, width, height, align, valign
  • TD 표의 칸
  • TH 표의 제목
  • bgcolor, width, border, cellspacing, cellpadding
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>테이블 태그 테스트</title>
</head>
<body>


    <h3>테이블 태그 테스트</h3>
    <table border = "1" bgcolor = "pink">

        <tr bgcolor="skyblue">
        <th>이름</th><th>나이</th><th>직업</th>
        </tr>

        <tr>
        <td bgcolor = "yellow">기묜진</td><td>28</td><td rowspan="3">꼬집기 선수</td>
        </tr>

        <tr>
        <td>이딘듀</td><td>1</td>
        </tr>

        <tr>
        <td>이비키</td><td>2</td>
        </tr>

        <tr>
        <td colspan="2" align = "center">학생수</td><td align = "right">3명</td>
        </tr>
          <h3>테이블태그 테스트</h3>
  <table border="1" bgcolor="ddffdd" width="50%"
         cellpadding="10"><!-- width="300" -->
    <!-- tr:테이블의 행표현,  th:열의 제목표현,  td:출력 데이터 -->
    <caption>Person정보</caption>
    <tr bgcolor="skyblue">
     <th width="20%">이름</th><th width="30%">나이</th><th width="50%">직업</th>
    </tr>
    <tr>
     <td bgcolor="yellow">홍길동</td><td>13</td><td rowspan="3">학생</td>
    </tr>
    <tr> 
     <td>길라임</td><td>15</td>
    </tr> 
    <tr> 
     <td>김주원</td><td>17</td>
    </tr> 
    <tr>
     <td colspan="2" align="center">학생수</td><td align="right">3명</td>
    </tr>
  </table>
  <hr/>

  <h3>테이블태그 테스트</h3>

  <table border="1" bgcolor="ddffdd" width="50%"
         cellspacing="10"><!-- width="300" -->
    <!-- tr:테이블의 행표현,  th:열의 제목표현,  td:출력 데이터 -->
    <caption>Person정보</caption>
    <tr bgcolor="skyblue">
     <th width="20%">이름</th><th width="30%">나이</th><th width="50%">직업</th>
    </tr>
    <tr>
     <td bgcolor="yellow">기묜진</td><td>13</td><td rowspan="3">학생</td>
    </tr>
    <tr> 
     <td>이딘듀</td><td>15</td>
    </tr> 
    <tr> 
     <td>이비키</td><td>17</td>
    </tr> 
    <tr>
     <td colspan="2" align="center">학생수</td><td align="right">3명</td>
    </tr>
  </table>
    </table>

</body>
</html>

궁금상자 
    - Markup언어와 Markdown언어
Markup은 문서의 구조를 정의, tag로 둘러쌓여있음, 문서 골격에 해당하는 부분 작성

Markdown은 마크업 언어의 일종, 읽기도 쓰기도 쉬움 @ 같은 것이나 해쉬태그가 마크다운
궁금상자
    - html에서 < > & 표시하고 싶으면?
&lt; &gt; &amp; 쓰거나,  2바이트 전각문자 사용하면 됨
lt : Less Than
gt : greater Than
amp : ampersand
quot : 쌍따옴표
궁금상자
    - br p nbsp는 뭐의 약자?
br : Line Break
p : paragraph
nbsp : non-breaking spaces

+ Recent posts