자바스크립트

 

array.html

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<script type="text/javascript">
fruits=new Array(); //배열 변수 선언
fruits["a"]="사과"; 
fruits["b"]="바나나";
fruits["c"]="오렌지";

//자바는 대괄 자바스크립트는  중괄호 사용
fruits2= ["a", "b","c"];

/* 

숫자 인덱스 인경우
for(var i=0; i<fruits.length; i++){
	document.write(fruits[i]+ "<br/>");
}
 */
for( f in fruits){
	
	document.write(fruits[f]+ "<br/>");
	
}

for( f in fruits2){
		
		document.write(fruits2[f]+ "<br/>");
		
}
</script>


</head>
<body>



</body>
</html>

 

사과
바나나
오렌지
a
b
c

 

 

 

dan.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">

#result{

	width: 300px;
	height: 500px;
	background: yellow;

}

</style>

<script>


function gugu(){
	//태그에 입력한 값을 저장
	
	dan =document.getElementById("dan").value;
	var result=document.getElementById("result");
	result.innerHTML="";
	for(i=1; i<=9; i++){
		result.innerHTML +=dan+"x" +i+"="+dan*i+"<br>";
		//document.write(dan+"x" +i+"="+dan*i+"<br>");
	}
}

</script>

</head>
<body>



<input type="text" id="dan">
<button type="button" onclick="gugu()" >단을 입력하세요</button>



<div id="result">


</div>


</body>
</html>

 

 단을 입력하세요

5x1=5
5x2=10
5x3=15
5x4=20
5x5=25
5x6=30
5x7=35
5x8=40
5x9=45

 

 

confirm.html

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script>

function fn(){

	user =confirm("계속할까요?");
	if(user==true){
		document.write("계속합니다.");
	}else{
		document.write("종료합니다.");
	}

}

</script>

</head>
<body>

<button  type="button" onclick="fn()">확인</button>

</body>
</html>


 

확인


 

func.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<script>

function greeting(){
	
	name=document.getElementById("name").value;
	
	position=document.getElementById("position").value;
	
	str =name+ " " +position+ " 님 환영합니다.";
	
	document.form1.submit();
}

</script>

</head>
<body>


<form method="post" action="func_result.jsp" name="form1">

 이름 : <input id="name" name="name"><br/>
 직급 : <input id="position" name="position"><br/>
 <input type="button" value="확인" onclick="greeting()" />
 
</form>


</body>
</html>

 

이름 : 
직급 : 

 

func_result.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("utf-8"); %>

${ param.name} <br/>
${param.position }

</body>
</html>

 

한글 
한글22

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

about author

PHRASE

Level 60  머나먼나라

사랑은 눈이 멀기에 연애하는 자는 제아무리 아이들 같은 어리석은 짓을 하더라도 자기 눈에 보이지 않는다. -셰익스피어

댓글 ( 4)

댓글 남기기

작성