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

· 2013-11-25 (월) 01:35:48 · 2286 · 3
<!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개

2013-11-25 (월) 01:49:49
<input type='text' name='startTime' value='<?=rand(100,300)?>' style='width:30px;' />
2013-11-25 (월) 11:46:05
답변감사합니다.
근데 적용이 안됩니다.
박스안에 <?=rand(100,300)?> 이대로 표시가 됩니다.
감사합니다..
2013-11-25 (월) 14:26:37
<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 질문답변

66,531건

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

+
제목 글쓴이 날짜 조회
13-11-25 조회 3,061
13-11-25 조회 3,171
13-11-25 조회 2,235
13-11-25 조회 2,285
13-11-25 조회 2,548
13-11-25 조회 1,858
13-11-25 조회 2,872
13-11-25 조회 2,723
13-11-25 조회 1,377
13-11-25 조회 2,287
13-11-25 조회 2,381
13-11-24 조회 1,462
13-11-24 조회 1,840
13-11-24 조회 1,840
13-11-24 조회 1,869
13-11-24 조회 2,188
13-11-24 조회 1,750
13-11-24 조회 1,809
13-11-24 조회 2,640
13-11-24 조회 2,263