Yes. index.php is a string so it has to be inside quotes. Right now javascript is treating it like a variable.
i.e. It thinks that you are referring to variable named 'index' which is an object that has a member variable 'php'... so it is complaining that the 'index' variable has no index 'php'.
If that makes sense.
Best regards
Steve
OK. I changed it again and now it is:
require(DATAFACE_URL+'/js/ajax.js');
var types_http = null;
var type_group = null;
/**
* updateTypesList
* This function is to be assigned in the onchange handler for the group types select list.
*/
function updateTypesList(type_groups_select){
// type_groups_select is a reference to the type_groups select list
if ( types_http == null ) types_http = getHTTPObject();
var selectedGroup = type_groups_select.options[type_groups_select.selectedIndex].value;
alert ("" +selectedGroup+ ""); //shows the Index of selectedGroup, for example 2
//var url = DATAFACE_SITE_HREF +'?-action=get_types&type_group='+selectedGroup;
var url = 'index.php?-action=get_types&type_group='+selectedGroup;
alert ("" +url+ ""); // shows the url, which is now: index.php?-action=get_types&type_group=2
alert ("" +types_http+ ""); // shows [objekt XMLHttpRequest]
types_http.open("GET", url);
types_http.onreadystatechange = handleUpdateTypesList;
// Assign the handleUpdateTypesList function as a handler to be called when the HTTP object receives a response from the server
type_group = type_groups_select;
// Save a reference to the group types select list in the http object so that it can be accessed from the handleUpdateTypesList function
types_http.send(null);
}
/**
* handleUpdateTypesList
* This function is called when a response is received from the HTTP object after we request the types for a particular group.
*/
function handleUpdateTypesList(){
if ( types_http.readystate == 4 ){
alert ("Hello");
// We have successfully obtained the response from the server
if ( types_http == null ) types_http = getHTTPObject();
alert ("" +types_http.responseText+ "");
var options = eval('(' + types_http.responseText +')');
// we now have the options that we will use to fill the 2nd select list as an array
// now let's get out select list and refill it
var types_list = type_group.form.elements['type_group'];
// We obtain a reference to the type_id select list (let's assume that the field is named type_id.. if not, then change this).
// Clear the existing options in the types list.
for ( var i=0; i
}
}
}
The line
alert ("" +url+ ""); // shows the url, which is now: index.php?-action=get_types&type_group=2
is correct now, I think.
No errors in firefox but no results either. Second select remains (Please select...) No alerts of function handleUpdateTypesList show up.
I am too tired now to think about it. I will try and test again tomorrow.
Markus