웹프로그래밍

Global It Leader!!


컴퓨터언어


 
 

Javasript 중복안하는 랜덤 숫자 발생하기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 7,737회 작성일 10-11-10 09:17

본문

<script>
function setRand(min,max,number) {
    randResult = new Array();
    randList = new Array();
    for(i = min; i <= max; i++) {
    randList.push(i);
    }

    for(i = 0; i < number; i++) {
    getRand();
    }
    alert(randResult);
}

function getRand() {
    randNumber = Math.floor(Math.random() * randList.length);
    randResult.push(randList[randNumber]);
    randList.splice(randNumber,1);
}

//Min, Max, Number
setRand(7,10,3);
</script>

출처 : phpschool

댓글목록

등록된 댓글이 없습니다.

전체 112
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
12 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8325 05-07
11 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7448 05-03
10 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8021 04-29
9 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7236 04-05
8 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7204 12-16
열람중 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7738 11-10
6 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7305 10-03
5 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8830 08-28
4 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9188 06-15
3 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7733 05-10
2 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12015 04-29
1 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9423 03-14