value값을 랜덤으로 바뀌게 하려면 어떻게 하나요? 정보
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사이 랜덤으로 바뀌게 하려면 어떻게 하나요?
"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사이 랜덤으로 바뀌게 하려면 어떻게 하나요?
댓글 전체
<input type='text' name='startTime' value='<?=rand(100,300)?>' style='width:30px;' />
답변감사합니다.
근데 적용이 안됩니다.
박스안에 <?=rand(100,300)?> 이대로 표시가 됩니다.
감사합니다..
근데 적용이 안됩니다.
박스안에 <?=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/
<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/