문제 풀면 수우미양가 나오는 스크립트
페이지 정보
작성자 서방님 댓글 0건 조회 319회 작성일 07-08-30 18:22본문
<html>
<head>
<title>옛날시험</title>
<script>
/*
옛날 시험 문제 스크립트 2003-4-13
*/
function ck() {
//정답 배열
var ans=new Array('23','4','88','5');
//폼원소 개수
var s=0;
//맞은개수
var k=0;
//응시문항 개수
var chk=0;
//문서내 폼개수
var n=document.forms.length;
//폼 전체를 돌면서 확인
for (var i=0; i<document.forms.length; i++ ) {
//원소 배열
for( var j=0; j<document.forms[i].elements.length; j++) {
//폼 원소 배열
var ele = document.forms[i].elements[j];
//체크 확인
if (ele.checked) {
var item=document.forms[i].elements[j].value;
//정답이면 가산
if (item==ans[i]) {
k++;
}
chk++;
}
//내용
var v = document.forms[i].elements[j].value;
s++;
}
}
//점수
var p=Math.floor(k/n*100);
if (chk==0) {
alert('어머, 백지를...');
// history.go(-1)
}
else
sol(n,k,p) // 결과 출력 함수 호출
}
//결과 출력 함수
function sol(n,k,p) {
//메세지 출력
if (p<60) {
alert('당신의 성적은 가');
}
if ((p>=60)&&(p<70)) {
alert('당신의 성적은 양');
}
if ((p>=70)&&(p<80)) {
alert('당신의 성적은 미');
}
if ((p>=80)&&(p<90)) {
alert('당신의 성적은 양');
}
if ((p>=90)&&(p<100)) {
alert('당신의 성적은 수');
}
if (p==100) {
alert('당신의 성적은 1등~~');
}
var f=n-k;
//결과 출력
document.write('문항 개수 '+n+'<Br>'+'맞은개수 '+k+'<Br>'+'틀린개수 '+f+'<Br>'+'당신의 점수 '+p);
document.write('<p><a onClick=history.go(-1)><B>다시 도전</a>');
}
//초기화 함수
function re () {
for (var i=0; i<document.forms.length; i++ ) {
document.forms[i].reset();
}
}
</script>
<h4>옛날 시험지</h4>
<form><B>1) 10의 약수는 모두 몇 개일까요? =</b><Br>
<input type=radio name=1 value='1'>3개
<input type=radio name=1 value='23'>4개
<input type=radio name=1 value='32'>5개
<input type=radio name=1 value='33'>6개
</form>
<p>
<form>
<B>2) 다음중 노벨상을 받은 사람은?</b><Br>
<input type=radio name=2 value='4'>김대중
<input type=radio name=2 value='3'>깁영삼
<input type=radio name=2 value='2'>노태우
<input type=radio name=2 value='1'>전두환
</form>
<p>
<form>
<B>3) 태양계에서 가장 큰 행성은?</b><Br>
<input type=radio name=3 value='3'>토성
<input type=radio name=3 value='2'>천왕성
<input type=radio name=3 value='9'>해왕성
<input type=radio name=3 value='88'>목성
</form>
<form>
<B>4) 한자 無는 몇 획일까?</b><Br>
<input type=radio name=4 value='5'>12획
<input type=radio name=4 value='4'>11획
<input type=radio name=4 value='3'>10획
<input type=radio name=4 value='2'>14획
</form>
<input type=button onClick="ck()" value='다 풀었음'>
<input type=button onClick="re()" value='초기화'>
<p>
</html>
댓글목록
등록된 댓글이 없습니다.