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);
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.