Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing text of a variable from a php function

    All,
    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/a...?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:

    Code:
    parent.refreshText(cwainfo);
    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

    Code:
    function updateText() {
    callToServer('http://aviationweather.gov/testbed/afd/update.php?location=KLOT');
            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,
    Ryan

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    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

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •