[FX.php List] Creating summaries on the fly,

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Tue Aug 22 23:04:14 MDT 2006


On 23/8/06 1:48 PM, "Bob Patin" <bob at patin.com> wrote:

> Kevin,
> 
> This sounds like what I probably want; what I need to have is a variable that
> I can place in the table as it's built in the PHP foreach loop, and then
> update once the table's complete.
> 
> So in my table cell, would I put the code below, or is that how I update it?
> 
> If you could give me an example of each, that would be great...
> 
> What I'd love to know:
> 
> 1) what to put in the cell (assuming the variable was called "test" for now
> 2) what to put down in the code after the foreach loop to update my
> variable...
> 
> Sounds like exactly what I need though...
> 
Well, I¹ll have to make some assumptions about the way you¹re doing things,
so you¹ll need to accommodate or amend for those. You¹ll need to write a JS
function out in the <head> section of your document using PHP, or at least
pass any relevant PHP variables to the JS script. Then, call the JS function
at the end of your table, so that it runs and populates the relevant table
cells. I guess all I can do is give you the code that would loop through a
series of table cells and write some data in ­ you¹ll have to modify it to
suit exactly what you¹re doing.

function writePercentage()
{
    var rows = document.getElementsByTagName(³tr²);
    var total = rows.length;
    for (var i = 0; i < total; i++)
    {
        var target = document.getElementById(³id-name² + i);
        target.innerHTML = ³30%²;
    }
}

Of course, you¹d want to write an appropriate value into each cell ­ I¹ve
just shown a hard-coded example. You¹d probably have to supply variables via
PHP (eg, target.innerHTML = ³<?php echo $phpvar; ?>²; ), or calculate the
percentage yourself in the loop using PHP-supplied variables.

I hope all that makes sense! I¹d still go with Dale¹s PHP suggestions
though, FWIW.

-- 
Kevin Futter
Webmaster, St. Bernard's College
http://www.sbc.melb.catholic.edu.au/



------------------------------------------
This e-mail and any attachments may be confidential.  You must not disclose or use the information in this e-mail if you are not the intended recipient.  If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies.  The College does not guarantee that this e-mail is virus or error free.  The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not.  The content and opinions in this e-mail are not necessarily those of the College.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060823/414fbd3d/attachment.html


More information about the FX.php_List mailing list