HTML,CSS,JS 2019. 10. 5. 00:44

[완성품]

 

[코드]

<html>

 <head>

  <title> 06 </title>

  <script language="javascript">

   function previewString(){

  var objResult = document.getElementById("result");

  var objText = document.getElementById("tbString");

  var objFontColor = document.getElementById("fontColor");

  var objFontSize = document.getElementById("fontSize");

  var objOptions = document.getElementsByName("option");

 

  var targetString = objText.value;

 

  targetString = targetString.fontcolor(

  objFontColor.options[objFontColor.selectedIndex].value);

  targetString = targetString.fontsize(

  objFontSize.options[objFontSize.selectedIndex].value);

 

  if (objOptions[0].checked){

   targetString=targetString.strike();

  }

  if (objOptions[1].checked){

   targetString=targetString.bold();

  }

  if (objOptions[2].checked){

   targetString=targetString.italics();

  }

  if (objOptions[3].checked){

   targetString=targetString.toLowerCase();

  }

  if (objOptions[4].checked){

   targetString=targetString.toUpperCase();

  }

  objResult.innerHTML = targetString;

}

</script>

 </head>

 <body>

  <form>

   <input type="text" name="my_text" size="30" id="tbString">

   <input type="button" value="미리 보기"

   onclick="previewString()">

   <br>색상 : 

   <select id="fontColor">

    <option value="Red">빨강</option>

    <option value="Blue">파랑</option>

    <option value="Green">초록</option>

   </select>

   <br>크기 : 

   <select id="fontSize">

    <option value="1">1</option>

    <option value="2">2</option>

    <option value="3">3</option>

    <option value="4">4</option>

    <option value="5">5</option>

    <option value="6">6</option>

   </select>  <br>

    <input type="checkbox" name="option" value="cancel">취소선

    <input type="checkbox" name="option" value="thick">두껍게

    <input type="checkbox" name="option" value="tip">기울임<br>

    <input type="checkbox" name="option" value="s_letter">소문자로

    <input type="checkbox" name="option" value="b_letter">대문자로<br>

   <span id="result"></span>

  </form>

 </body>

</html>

'HTML,CSS,JS' 카테고리의 다른 글

[HTML]웹에 현재시간 추가하기  (0) 2019.10.06
[HTML] 초간단 표 만들기  (0) 2019.10.05
posted by 스노(Snow)
: