This code works to a fashion but after selecting the serial combo box a few times the browser freezes and does not come back. The section of code that is called is below.
toolTBar.attachEvent('onClick', function(id){
alert(id);
if(id == "allocTool") {
var windows = new dhtmlXWindows();
var winTooling = windows.createWindow('winTooling', 0, 0, 500, 240);
var frmTooling = winTooling.attachForm();
frmTooling.attachEvent("onXLE", function (){
var selTool = frmTooling.getCombo("T_ID");
selTool.loadXML("combo/tooling.php");
selTool.attachEvent("onSelectionChange", function(){
var id = selTool.getSelectedValue();
var selSerial = frmTooling.getCombo("SERIAL");
selSerial.loadXML("combo/serial.php?tool="+id);
selSerial.setComboText("");
selSerial.attachEvent("onSelectionChange", function(){
var s_id = selSerial.getSelectedValue();
frmTooling.load("php/serialTool.php?id="+s_id);
})
});
});
frmTooling.loadStruct("xml/toolingForm.xml");
frmTooling.enableLiveValidation(true);
winTooling.setText('Allocate Tool');
winTooling.denyResize();
winTooling.center();
}
});
Any help would be great as I am new to Javascript.
I think I fixed the above problem. The code was freezing as it got into a loop. Every time I loaded the form data the onXLE event was called again. So I rewrote the code using combobox’s.
What I am trying to code is to load different data based on the initial combo. The first combo selects a tool. When the tool is selected the next combo will hold the serial no’s for that tool. Which then fills the Make, Model and Inspection date.
Some tools do not have serial no’s or make but have a size (like a spanner). How can I trigger an event if no data is returned from the db connector ?
Thanks in advance.
toolTBar.attachEvent('onClick', function(id){
if(id == "allocTool") {
var windows = new dhtmlXWindows();
var winTooling = windows.createWindow('winTooling', 0, 0, 500, 240);
var frmTooling = winTooling.attachForm();
frmTooling.loadStruct("xml/toolingForm.xml");
winTooling.setText('Allocate Tool');
winTooling.denyResize();
winTooling.center();
frmTooling.attachEvent("onButtonClick", function(name, command){
//Code to save data
alert("Save");
frmTooling.send("php/allocateTools.php","post", function(loader, response) {
alert(response);
});
});
frmTooling.attachEvent("onXLE", function(){
var selTool = frmTooling.getCombo("T_ID");
selTool.loadXML("combo/tooling.php");
selTool.attachEvent("onXLE", function(){
selTool.selectOption(0);
});
var selSerial = frmTooling.getCombo("SERIAL");
var selMake = frmTooling.getCombo("MAKE");
var selModel = frmTooling.getCombo("MODEL");
var selCal = frmTooling.getCombo("CAL");
frmTooling.setItemValue("ISSUED",getCurrentDate());
selSerial.attachEvent("onXLE", function(){
selSerial.selectOption(0);
var cnt = selSerial.optionsArr.length;
if (cnt > 1 ) {
selMake.readonly(true);
selModel.readonly(true);
}
});
selTool.attachEvent("onSelectionChange", function(){
var id = selTool.getSelectedValue();
selSerial.loadXML("combo/serial.php?tool="+id);
selSerial.setComboText("");
var cnt = selSerial.optionsArr.length;
alert(cnt);
});
selSerial.attachEvent("onSelectionChange", function(){
var s_id = selSerial.getSelectedValue();
var cnt = selSerial.optionsArr.length;
alert(cnt);
if(cnt > 1) {
selMake.loadXML("combo/make.php?serial="+s_id);
selModel.loadXML("combo/modelSerial.php?serial="+s_id);
selCal.loadXML("combo/cal.php?serial="+s_id);
} else {
selModel.loadXML("combo/model.php"+selTool.getSelectedValue());
}
});
selModel.attachEvent("onXLE", function() {
selModel.selectOption(0);
});
selMake.attachEvent("onXLE", function() {
selMake.selectOption(0);
});
selCal.attachEvent("onXLE", function() {
selCal.selectOption(0);
});
//frmTooling.enableLiveValidation(true);
});
}
});
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan