View Full Version : Printing text of a variable from a php function

06-24-2009, 11:17 AM
While the title says php on a javascript forum, it will get back to javascript. A php function already exists that strips a text products from the National Weather Service into just a portion of that text, which is what I want to display on my page. This php function, courtesy of the NWS, is available at this url: http://aviationweather.gov/testbed/afd/update.php?location=KLOT The text can be seen in the source code. It is assigned to the variable "cwainfo" and returned to a javascript in whatever the parent page is, at the end of the code:


All I want to do is display the text that is in cwainfo on my page. So if I call to that page with a script, something like

function updateText() {
return true;

...then how would I get to display that cwainfo code on my home page, which would be the parent page? It would have to be some function. This may be basic, and I feel like it is, but I cannot get it to work.

Thank you,

06-24-2009, 02:53 PM
assuming you're as far as getting the correct info returned to a variable, it's as simple as setting the innerHTML of a target element.

if "target" is the id of the element you want to display the results in and "content" is the variable containing the response... then drop something like this in your function

document.getElementById('target').innerHTML = content;