This topic is locked
[SOLVED]

 Progress Bar Integration

11/13/2013 6:44:13 AM
PHPRunner General questions
V
vic4nze author

Hello,
I would like to email selected records from table A before a record is added on another table B. I have the email loop set up on the Before Record Added Event of table B and it's working well but would like to show a progress bar of emails being processed on the Add Page. I have this progress bar script but could not get it to work in my application:



$total = 10;

// Loop through process

for($i=1; $i<=$total; $i++){



$percent = intval($i/$total * 100)."%";
//######## Email script goes here #######



// Javascript for updating the progress bar and information

echo '<script language="javascript">

document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\">&nbsp;</div>";

document.getElementById("information").innerHTML="'.$i.' row(s) processed.";

</script>';


// This is for the buffer achieve the minimum size in order to flush data

echo str_repeat(' ',1024*64);


// Send output to browser immediately

flush();


// Sleep one second so we can see the delay

sleep(1);

}

// Tell user that the process is completed

echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>';


I have this place on the add page through the HTML Editor:



<div id="progress" style="width:500px;border:1px solid #ccc;"></div>

<!-- Progress information -->

<div id="information" style="width"></div>


Pls any suggestions on how to get this working. Tanx

Sergey Kornilov admin 11/13/2013

It won't work that way. Anything Javascript related won't be shown to the end user until server side code is fully processed.
Try to output something right to the screen right from the event code. Not guaranteed to work either as browser may cache the output.

V
vic4nze author 11/13/2013



It won't work that way. Anything Javascript related won't be shown to the end user until server side code is fully processed.
Try to output something right to the screen right from the event code. Not guaranteed to work either as browser may cache the output.



Thanks Sergey for your reply.
Any ideas on how progress bar could be implemented in PHPRunner generated Application?

Sergey Kornilov admin 11/13/2013

This is a complicated task and solution will be completely different depending on what sort of task you need to track. In your case you can try simple echo statement from BeforeAdd event.