웹프로그래밍

Global It Leader!!


jQuery


 
 

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

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 6,925회 작성일 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 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 11152 04-29
141 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8744 03-14
140 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8377 06-15
139 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8052 08-28
138 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7630 05-07
137 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7334 06-16
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6926 11-10
135 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6859 04-29
134 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6798 05-10
133 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6726 07-26
132 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6668 09-17
131 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6445 06-01
130 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6441 07-13
129 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6321 10-03
128 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6314 04-05
127 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6303 06-14
126 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6299 05-03
125 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6270 12-16
124 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6222 05-13
123 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6080 05-30