I think the answer lies with using a second onload event. This would make FitPic() variables accessible (I think). However, the second onload needs to fill a textbox or other html tag on the page. That's where I'm struggling.
My current code is structured like this. It obviously fails because I'm trying to render the ScaleAmt() function using variables that aren't accessible until the onload FitPic() fires.
Expand|Select|Wrap|Line Numbers
- function FitPic() {
- ImgWidth = [new image width calculated through this function]
- OriginalImgWidth = [original image width]
- }
- function ScaleAmt() {
- o = OriginalImgWidth;
- n = ImgWidth;
- r = parseInt((n/o) * 100);
- return r;
- }
- <body onload="FitPic();>
- then later....
- document.write( "<p>Image is " + ScaleAmt() + "% of original size</p>");
- </body>
Thanks for any and all help.