ghurty Posted August 17, 2007 Share Posted August 17, 2007 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 https://forums.phpfreaks.com/topic/65442-how-to-use-ajax-to-refresh-a-script-wo-refreshing-page/ Share on other sites More sharing options...
adam84 Posted August 17, 2007 Share Posted August 17, 2007 use javascript( setInterval() ) to call the ajax function every 5 or whatever seconds Link to comment https://forums.phpfreaks.com/topic/65442-how-to-use-ajax-to-refresh-a-script-wo-refreshing-page/#findComment-327014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.