웹프로그래밍

Global It Leader!!


jQuery


 
 

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

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 6,902회 작성일 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 목록
번호 제목 글쓴이 조회 날짜
142 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 11127 04-29
141 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8723 03-14
140 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8356 06-15
139 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8028 08-28
138 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7608 05-07
137 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7304 06-16
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6903 11-10
135 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6834 04-29
134 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6777 05-10
133 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6704 07-26
132 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6630 09-17
131 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6424 06-01
130 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6419 07-13
129 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6295 10-03
128 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6294 04-05
127 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6285 06-14
126 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6277 05-03
125 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6249 12-16
124 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6204 05-13
123 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6061 05-30