View Full Version : Functions
Raulphzxie
09-17-2002, 12:33 AM
Is there a way to make a function go off a certain amount of times?
adios
09-17-2002, 01:06 AM
Pretty skimpy description...:confused:
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">
function go_off(times, sec_delay) {
if (times) go_off.how_many_times = Number(times);
status = 'going off ' + go_off.how_many_times + ' more times...'; //display
if (go_off.how_many_times--) setTimeout('go_off(null,'+sec_delay+')',sec_delay * 1000);
}
</script>
</head>
<body>
<a href="javascript:void go_off(prompt('How many times would you like?','number'),1)">
go</a><br><br>
<h4>watch the status</h4>
</body>
</html>
a more mundane example...
<html>
<head>
<title>Function Call</title>
<script language="javascript" type="text/javascript">
<!--
function doit(i){
alert("Calling doit(i)"+i+" times")
}
function callDoit(){
for(var i=1; i<=4; i++){
doit(i)
}
}
// end hide -->
</script>
</head>
<body>
<a href="javascript: callDoit()">Call the Function</a>
</body>
</html>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.