Jump to content

How to use ajax to refresh a script w/o refreshing page?


ghurty

Recommended Posts

I have a script that runs based on calculations from a variable in a drop down list.

 

For example, You choose a city from a drop down list, and it calculates and displays sunrise, sunset, tides, etc...

 

As of now, I have it that when you make a change, it refreshes the entire page. How would I go about makeing it that it only reruns the script? and changes that particular part?

 

Thanks:

<form name="mainform" action="index.php" method="get">
<input type="hidden" name="option" value="com_sched" />
<select name="activelocation" onchange="submit();">
<?php fillLocationList($activelocation); ?>

 

<?php
if(isset($_GET['activelocation'])){
$location = $_GET['activelocation'];
setcookie('location', $location, time()+60*60*24*30);
} elseif(isset($_COOKIE['location'])){
$location = $_COOKIE['location']; //if the cookie is set, get the value
} else{
setcookie('location', 'New York, NY', time()+60*60*24*30);
$location = "New York, NY";
}
$day = date("j");
$month = date("n");
$year = date("Y");
if ($location != "") {
$caption = "Suntimes and Tides for $day $month $year, $location";
$caption2.="<a href=\"index.php?option=com_sched\"> Click here to change default city </a>";
$elevation = $location[3];
CalculateZmanimForDay($month, $day, $year, $location[0], $location[1], $location[2], $elevation, $caption, $caption2);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.