웹프로그래밍

Global It Leader!!


jQuery


 
 

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

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 6,914회 작성일 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

댓글목록

등록된 댓글이 없습니다.

전체 142
게시물 검색
jQuery 목록
번호 제목 글쓴이 조회 날짜
22 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6713 07-26
21 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5062 07-26
20 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6295 06-14
19 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5894 06-13
18 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6039 06-09
17 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6433 06-01
16 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6074 05-30
15 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5594 05-26
14 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5687 05-13
13 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6216 05-13
12 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7619 05-07
11 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6288 05-03
10 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6846 04-29
9 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6303 04-05
8 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6261 12-16
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6915 11-10
6 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6308 10-03
5 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8041 08-28
4 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8368 06-15
3 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6788 05-10