테스트 사이트 - 개발 중인 베타 버전입니다

자바스크립트 텍스트박스에 랜덤으로 출력

</strong> </p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;"><input type="text" id="sc" name="sc" value=""></span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;"><Script Language="JavaScript"></span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;"><!--//</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A=new Array();</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[0]="Gift Ideas"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[1]="Toys"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[2]="Travel"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[3]="Digital Cameras"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[4]="Email"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[5]="Flowers"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[6]="DVDs"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">A[7]="Travel"</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">rand = Math.floor( A.length * Math.random());</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">randText = A[rand];</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">search.sc.value = randText;</span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;">//--></span></font></p><p><font color="#333333" face="trebuchet ms, arial, sans-serif"><span style="font-size: 13px; line-height: 20.8px;"></Script></span></font></p><div style="color: rgb(51, 51, 51); font-family: 'trebuchet ms', arial, sans-serif; font-size: 13px; line-height: 20.8px; background-color: rgb(255, 255, 255);"><div class="copy_egloos">
</div></div><p><strong style="color: rgb(127, 127, 127); font-family: 돋움, Dotum, sans-serif; font-size: 12px; letter-spacing: -0.01px; line-height: normal;">
 

 

텍스트박스안에 1~7까지 중에 랜덤으로 넣어줄려고 하는데 안되네요 ㅠㅠ 도와주세요

 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

</p><p><!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form name="search" id="search">
<input type="text" id="sc" name="sc" value="">
</form>
<script>
<!--//
A=new Array();
A[0]="Gift Ideas"
A[1]="Toys"
A[2]="Travel"
A[3]="Digital Cameras"
A[4]="Email"
A[5]="Flowers"
A[6]="DVDs"
A[7]="Travel"
rand = Math.floor( A.length * Math.random());
randText = A[rand];
search.sc.value = randText;
//-->
</script>
</body>
</html></p><p>

이렇게 하시면 될 것 같습니다. 테스트하니 정상적으로 잘 동작합니다. 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

해당 소스로 잘 되는데요?

 

input 위에 form 네임이 search가 맞는지 확인 하면 될 것 같습니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고