Hi. I’ve made a form to book places on training courses - all seemed to be working fine - but have now found a problem.
When you choose a course from a combobox, it populates another combobox with the relevant dates. When you choose a date it puts the relevant time and venue information in a dynamic text field. The courses, dates and time/venue info all come from an external text file (see attached). Problem is that for 9 of the dates it displays the wrong time/venue - and i can’t for the life of me figure out why. I thought it would just be a typo in the text file , but can’t see anything wrong there. it just seems to be calling the wrong variable for no reason - ie. instead of calling the variable c2t2 it’s calling c11t2.
here’s the code from my fla (i’m using flash 8)
stop();
// EXTERNAL VAR
var loadCourses:LoadVars = new LoadVars();
loadCourses.onLoad = function() {
//loads courses, dates and times
var totalcourses=(parseInt(loadCourses.totalcourses))+1;
courses = new Array(totalcourses);
totaldatesForCourse = new Array(totalcourses);
dates = new Array(totalcourses);
times = new Array(totalcourses);
for (var i:Number = 0; i<totalcourses; ++i){
courses* = this["c"+i];
totaldatesForCourse* = parseInt(this["totaldates"+i])+1;
dates* = new Array(totaldatesForCourse*);
times* = new Array(totaldatesForCourse*);
for (var j:Number = 0; j<totaldatesForCourse*; ++j){
dates*[j] = this["c"+i+"d"+j]
times*[j] = this["c"+i+"t"+j]
}
title_cb.dataProvider = courses;
}
//listener for titles dropdown
var myListener:Object = new Object();
title_cb.addEventListener("change", myListener);
myListener.change = function() {
for (var i:Number = 0; i<courses.length; ++i) {
if (title_cb.selectedItem == courses*) {
date_cb.dataProvider = dates*;
clearThings();
if(title_cb.selectedItem == courses[0]) {
date_cb.enabled = false;
}
}
}};
// listener for dates drop down
var myListener:Object = new Object();
date_cb.addEventListener("change", myListener);
myListener.change = function() {
for (var i:Number = 0; i<courses.length; ++i) {
for (var j:Number = 0; j<50; ++j) {
if (date_cb.selectedItem == dates*[j]) {
time = times*[j]
if(date_cb.selectedItem == dates*[0])
time = ""
}}
}
};
};
loadCourses.load("etdtest.txt");
// things that need to happen when a course is chosen
clearThings = function() {
date_cb.enabled = true;
time = ""
}
this.next2_btn.onRelease = function(){
;
checkThis();
if(time == ''){
error2 = "Please choose a course or programme and check all the required fields are completed"
} else {
details2 = "Course title: " + title_cb.value +newline + "Date: " + date_cb.value +newline + time
trace(details2)
error2 = ""
}}
Can anyone out there help??
and please don’t tell me to use xml instead - i don’t know how and don’t have time to learn right now.