AnsweredAssumed Answered

Using javascript setTimeout to send text to FileMaker?

Question asked by anchorbuoy on Apr 10, 2015
Latest reply on May 7, 2015 by anchorbuoy

I’m trying to use setTimeout to facilitate communication between a web viewer and FileMaker, but having some issues sending a parameter to setTimeout in a loop.

 

This is the loop function, but every time it runs it just repeats the highest number ("10") 10 times. I tried adopting the "bind" method from http://stackoverflow.com/questions/1190642/how-can-i-pass-a-parameter-to-a-settimeout-callback but either I'm implementing it incorrectly or it's not compatible inside a webviewer (on Mac, at least).

 

function writeCount(){

  for ( i=0; i < 10 ; i++) {

  setTimeout(

  function(){

  sendText(i);

  document.getElementById('countBox').innerHTML=document.getElementById('countBox').innerHTML + i + '<br/>';

  } ,

  i * 150

  );

  }

}

 

For reference (although it's not important to the core problem), this is the javascript function that sends information back into FileMaker via the FMP protocol. This is fired from within a webviewer, and I've confirmed it works in both Windows and Mac.

 

function sendText(text) { window.location="fmp://$/jsCallback?script=writeme(text)&param="+text; }

 

The sample file is attached. Any suggestions?

 

Thanks!

~ Cristos

Attachments

Outcomes