福报来之前的10征兆:怎样在文本框中通过点击按扭产生一个大于0小于1000的随机整数?

来源:百度文库 编辑:中科新闻网 时间:2024/05/04 19:53:40
要的是代码,谢谢。
用VB编写,将command1 click的程序代码写出。

<script>
function test()
{
document.getElementById("input1").value=(Math.floor(Math.random()*999+1));
}
</script>
<input type="text" id="input1">
<input type="button" onclick="test()" value="确定">

你用什么开发工具啊?
在DELPHI里是这样的:

var
i: Integer;
begin
i := Random(1001);
Edit1.Text := IntToStr(i); //Edit1就是文本框
end;

int(ran(1)*1000)

这是一个网页,
<script language=vbscript>
sub aa()
dim thevalue
randomize
thevalue=int(rnd(1)*1000)+1
document.f1.text1.value=thevalue
end sub
</script>
<body>
<form name="f1">
<input type=text id=text1 name="text1">
<br>
<input type=button value="show" onclick="aa">
</form>
</body>