글
textarea크기 조절하는 스크립트
Java Script
2011. 9. 1. 19:46
안녕하세요?
오늘도 소스분석입니다. 오늘은 textarea라고 글상자의 크기를 가변적으로 늘렸다 줄였다 하는 소스입니다. 별로 유용할거 같지는 않지만 그냥 재미있을거 같아서 올립니다. 소스를 보실까요?
<form name="form1" method=post action="http://www.jasko.co.kr/result.html" onsubmit="">
<input type="button" name="button1" onclick="javascript:this.form.area.rows +=1" value=" R++ ">
<input type="button" name="button1" onclick="javascript:this.form.area.rows -=1" value=" R-- ">
<input type="button" name="button1" onclick="javascript:this.form.area.cols +=1" value=" C++ ">
<input type="button" name="button1" onclick="javascript:this.form.area.cols -=1" value=" C-- ">
<p>
<textarea name="area" rows="10" cols="50"></textarea>
</form>
여기서 유의해서 봐야 할 것은 onclick="javascript:this.form.area.rows +=1" 부분입니다. 즉 버튼을 클릭하면 뒤의 자바스크립트 코드를 실행하는데 그 코드가 this.form 폼의 area, textarea의 name속성이죠. area의 rows을 +1 시키는겁니다. 하나 증가시키는 거죠. 만약에 +5하면 5줄 증가시키게 될겁니다. 마찬가지로 다른 버튼들은 줄였다 cols를 늘였다 줄였다 하는겁니다. 이해하시겠지요? 한번 직접 실행해 보시기 바랍니다.
오늘도 소스분석입니다. 오늘은 textarea라고 글상자의 크기를 가변적으로 늘렸다 줄였다 하는 소스입니다. 별로 유용할거 같지는 않지만 그냥 재미있을거 같아서 올립니다. 소스를 보실까요?
<form name="form1" method=post action="http://www.jasko.co.kr/result.html" onsubmit="">
<input type="button" name="button1" onclick="javascript:this.form.area.rows +=1" value=" R++ ">
<input type="button" name="button1" onclick="javascript:this.form.area.rows -=1" value=" R-- ">
<input type="button" name="button1" onclick="javascript:this.form.area.cols +=1" value=" C++ ">
<input type="button" name="button1" onclick="javascript:this.form.area.cols -=1" value=" C-- ">
<p>
<textarea name="area" rows="10" cols="50"></textarea>
</form>
여기서 유의해서 봐야 할 것은 onclick="javascript:this.form.area.rows +=1" 부분입니다. 즉 버튼을 클릭하면 뒤의 자바스크립트 코드를 실행하는데 그 코드가 this.form 폼의 area, textarea의 name속성이죠. area의 rows을 +1 시키는겁니다. 하나 증가시키는 거죠. 만약에 +5하면 5줄 증가시키게 될겁니다. 마찬가지로 다른 버튼들은 줄였다 cols를 늘였다 줄였다 하는겁니다. 이해하시겠지요? 한번 직접 실행해 보시기 바랍니다.
'Java Script' 카테고리의 다른 글
엔터키를 치면 다음칸으로 이동 (0) | 2011.09.06 |
---|---|
마우스로 클릭하면 글상자의 글이 선택됩니다 (0) | 2011.09.04 |
간단한 디지탈 시계 (0) | 2011.08.30 |
간단한 계산기 (0) | 2011.08.28 |
버튼-새창띄우기 (0) | 2011.08.25 |