views:

303

answers:

1

Whats wrong with this function?

function yahooWeather(){
    var loadPage = 'yahooweather.php?p='+ $("#myCity").val();
    $("#yahoo").html('<img src="loading.gif" align="absmiddle">');
    $("#yahoo").load(loadPage);
}

Is there another way to write this function. Im unsure if its able to read the .val required, tho i know it is set as i used it in a previous function to test that it was being set, so im thinking its maybe my load call.

http://www.wetterkanal.tv/

This is the page. This function once called by clicking the button, should get the value set by the "select city" option then load the weather in a div below. I have set the css to this div as green so i know it loads. I also know that my php script works as if i test it by going to the following:

http://wetterkanal.tv/yahooweather.php?p=ASXX0001

it pulls the weather in correctly. Please help!

+1  A: 

Your problem is that the button element will reload the page when the button is clicked.

You need to change your onclick attribute to onclick="yahooWeather(); return false;".

SLaks
Thank you. Solved so simple yet i never thought of it...
ChrisMJ