JAVASCRIPT&JQUERY
자바스크립트 별찍기(파이썬7)
9400
2023. 1. 10. 14:39
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
#it_first,#it_last{
width : 50px;
}
</style>
<script type="text/javascript">
function myclick(){
let it_first = document.querySelector('#it_first').value;
let it_last = document.querySelector('#it_last').value;
text="";
for(i=it_first; i<=it_last; i++){
text+=strStar(i);
}
document.querySelector('#str').value = text;
}
function strStar(j){
ret="";
for(i = 0; i<j; i++){
ret +="*";
}
ret +="\n";
return ret;
}
</script>
</head>
<body>
<table border="1">
<tr>
<td>첫번째별수:</td>
<td>
<input type="text" id="it_first" />
</td>
</tr>
<tr>
<td>끝별수:</td>
<td>
<input type="text" id="it_last" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" value="출력하기" onclick="myclick()" />
</td>
</tr>
<tr>
<td colspan="2">
<textarea rows="10" cols="10" id="str"></textarea>
</td>
</tr>
</table>
</body>
</html>