You are here: irt.org | FAQ | JavaScript | Form | Q1335 [ previous next ]
Try:
<html>
<head>
<script language="JavaScript"><!--
var cnt=0;
var Qs = new Array(
'Question 1?',
'Question 2?',
'Question 3?',
'Question 4?',
'Question 5?'
);
function next(theForm) {
theForm.question.value=Qs[cnt];
cnt++
if (cnt >= Qs.length) cnt = 0;
}
//--></script>
</head>
<body onLoad="next(document.forms[0])">
<form onSubmit="return false">
<input type="text" name="question" value="">
<input type="button" value="next..." onClick="next(this.form)">
</form>
</body>
</html>