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

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

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

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

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>

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.