Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1456 How come in long running loops, the form fields do not get set before the loop begins?

You are here: irt.org | FAQ | JavaScript | Form | Q1456 [ previous next ]

Perhaps the browser does not have time to render it. Try this instead:

<form name="form1">
<input type="text" name="test1">
</form>

<script language="JavaScript"><!--
function f_start() {
  j=0;
  //setting form field before loop
  document.form1.test1.value="Counting";
  setTimeout('longLoop()',10);
}

function longLoop() {
  for (i=0; i<=1000000; i++,j++) ;
}
//--</script>

©2018 Martin Webb