Hi, I am very much new in AJAX, I used a sample AJAX script (ajax-chained-select) from the site and customized it to fit for my requirement and used in my code, this is working absolutely fine with IE, but when the same thing opened in Mozilla, it throw an error (document.getElementById("CourseDateID") has no properties in the file dynamic_list.php - line no: 403), please help me out dear friends. I attach the code also along with this.
I need to fetch the and display all the CourseDates in the second select box (Name : CourseDateID) on the change of the first select box (Name: CourseID)
---------------- IN THIS FILE, I HAVE INCLUDED THE AJAX SRIPT -------
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
function createCertificates()
{
var obj = document.getElementById('CourseDateID');
//alert (ajax.response)
eval(ajax.response); // Executing the response from Ajax as Javascript code
}
var ajax = new sack();
function getCertificateList(sel)
{
var CourseID = sel.options[sel.selectedIndex].value;
//alert(CoachTypeCode)
document.getElementById('CourseDateID').options.length = 0; // Empty certificate select box
if(CourseID.length>0){
ajax.requestFile = 'getCourseDates.php?CourseID='+CourseID;
// Specifying which file to get
ajax.onCompletion = createCertificates; // Specify function that will be executed after file has been found
ajax.runAJAX();
// Execute AJAX function
}
}
---------------------------------------------------------------------
my php file is : getCourseDates.php?CourseID='+CourseID
-------------------------------------------------------------------------
<?php
include "../include/inc.mysql.php";
if( isset($CourseID) && ($CourseID != "-") ){
$sql="select ID,concat(date_format(DateStart,'%d %b %Y'),' - ',date_format(DateEnd,'%d %b %Y')) as CourseDates from CourseDate where CourseID=$CourseID order by DateStart" ;
$sql_query=mysql_query($sql) or die ("error in fetching curresponding course dates:".mysql_error());
echo "obj.options[obj.options.length] = new Option(\"-Choose One-\",\"0\");\n" ;
while ($CourseDateDetails = mysql_fetch_array($sql_query)){
$CourseDateID=$CourseDateDetails["ID"] ;
$CourseDates=$CourseDateDetails["CourseDates"] ;
echo "obj.options[obj.options.length] = new Option(\"$CourseDates\",\"$CourseDateID\");\n" ;
}
}
?>
----------- please tell me where I went wrong...
Thank you very much in advance.