Value from end of script displayed to top of page

I want to display the time it takes to execute a script at the top of a page not the bottom. I’m having trouble thinking about how to do that.

I’ll make the time calc with php, but don’t know how to display the calc at the top of the page

Can you get me pointed in the right direction?

If you are doing a crude benchmark test I don’t know why it would need to be at the top, And I don’t know what parts you are wanting to do with PHP and what parts with JavaScript.

Got any example code with only enough to show the idea or an outline of the logic flow?

I need it at the top else it would be buried by a potentially long table of results. Plus, I suddenly realized the solution to this tangent problem didn’t pop in to my head and it couldn’t get it to google.

I just needed some direction, but I kept working the problem.

I suddenly remembered to put the script at the bottom of page. Viola! My problem was mostly solved.

this took care of the rest of it:

I tried to put my script here several times, but it wouldn't display. 

Just having a forum to think out loud is a huge asset.

Thanks always for caring Mittineague!

if you stick to the IPO Model then all your PHP processing is done before the first line of your HTML. so the results are available to be put at any place.

This is what I did at the end of my script:

...
$runtime = $end - $start;
?>
<script type="text/javascript">
var runtime2 = <?php echo $runtime; ?>; 
document.getElementById("p1").innerHTML = runtime2;
</script>

The composer currently uses a combination of Markdown, bbCode, and HTML.
Don’t feel alone, many have problems with it. (especially when it wants to strip out tags)

Two ways I know of

Select the code block and click the </> icon in the toolbar (indents block 4 spaces each line)

this took care of the rest of it:
<script type="text/javascript">
  var runtime2 = <?php echo $runtime; ?>; 
   document.getElementById("p1").innerHTML = runtime2;     

</code> 

Or put 3 backticks ```on their own line before and after the code block

this took care of the rest of it:
<script type="text/javascript">
  var runtime2 = <?php echo $runtime; ?>; 
   document.getElementById("p1").innerHTML = runtime2;     

</code>

EDIT
Ah, It looks like you figured it out on your own :thumbsup:

* for inline <tags> a single backtick before and after will work

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.