런

value값을 랜덤으로 바뀌게 하려면 어떻게 하나요?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Jason Chavannes" />
<title>jQuery Timer Demo</title>

<link rel="stylesheet" href="res/style.css" />
<script type="text/javascript" src="res/jquery.min.js"></script>
<script type="text/javascript" src="jquery.timer.js"></script>
<script type="text/javascript" src="res/demo.js"></script>
</head>
<body>

<h3>Example 2 - Countdown Timer</h3>
<span id="countdown">05:00:00</span>
<form id="example2form">
<input type='button' value='Play/Pause' onclick='Example2.Timer.toggle();' />
<input type='button' value='Stop/Reset' onclick='Example2.resetCountdown();' />
<input type='text' name='startTime' value='300' style='width:30px;' />
</form>
</body>
</html>

value='300' 에서 숫자를 100-300사이 랜덤으로 바뀌게 하려면 어떻게 하나요?
|

댓글 3개

<input type='text' name='startTime' value='<?=rand(100,300)?>' style='width:30px;' />
답변감사합니다.
근데 적용이 안됩니다.
박스안에 <?=rand(100,300)?> 이대로 표시가 됩니다.
감사합니다..
<body>
<script>
function myRandom(max, min) {
return Math.floor(Math.random()*(max-min)) + min;
}
var rand = myRandom(100,300);
$('#startTime').val(rand);
</script>

<h3>Example 2 - Countdown Timer</h3>
<span id="countdown">05:00:00</span>
<form id="example2form">
<input type='button' value='Play/Pause' onclick='Example2.Timer.toggle();' />
<input type='button' value='Stop/Reset' onclick='Example2.resetCountdown();' />
<input type='text' name='startTime' id='startTime' value='' style='width:30px;' />
</form>
</body>
</html>

http://jsfiddle.net/vkz2A/2/
댓글을 작성하시려면 로그인이 필요합니다.

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
13-11-25 조회 3,086
13-11-25 조회 3,186
13-11-25 조회 2,250
13-11-25 조회 2,297
13-11-25 조회 2,563
13-11-25 조회 1,876
13-11-25 조회 2,894
13-11-25 조회 2,739
13-11-25 조회 1,397
13-11-25 조회 2,305
13-11-25 조회 2,400
13-11-24 조회 1,480
13-11-24 조회 1,863
13-11-24 조회 1,860
13-11-24 조회 1,899
13-11-24 조회 2,204
13-11-24 조회 1,763
13-11-24 조회 1,830
13-11-24 조회 2,657
13-11-24 조회 2,274