Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1335 How can I pass a set of questions (one at a time) to a document.form.field.value with every click on a form button?

irt.org | Knowledge Base | JavaScript | Form | Q1335 [ previous next ]

Q1335 How can I pass a set of questions (one at a time) to a document.form.field.value with every click on a form button?

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.