I have a program running a query and creating xml data islands, which are saved to file (purely for debugging reasons) and then output using a javascript function.
The results i am getting are very unpredictable though, although i have data in the xml island, my javascript function is showing nothing in it sometimes.
this query:
Select * from incident where (upper(description) containing upper('out') and companyid = 9)
gives me this data island:
and yet my select box shows nothing. Most of the time this function is working. a perfect example is if i type "the" into the text box, i get nothing, but if i type "ther" into the text box i get 6 records shown.
I know that 20 records are returned with "the" because the data island is saved with these records in them. however,
shows "0" and no records are displayed in bob.
Can anyone tell me why this is not working on some search criteria but is on others???
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!
The results i am getting are very unpredictable though, although i have data in the xml island, my javascript function is showing nothing in it sometimes.
Code:
// Fill combo with XML data
function searchinc(par, company, id, text) {
var currNode;
var strQuery;
if (text.value.length >= 3){
XMLID.async = false;
// Change Ddata Island source
strQuery="Select * from incident where (upper(description) containing upper('" + par + "') and companyid = " + company + ')';
//the following would not work without Absolute Path
XMLID.SRC="[URL unfurl="true"]http://localhost/cgi-bin/XMLSearch.exe/main?QString="[/URL] + strQuery + "&search=inc";
// Get all "names" from XML data
objNodeList = XMLID.getElementsByTagName("description");
objNumberList = XMLID.getElementsByTagName("form_no");
objindex = XMLID.getElementsByTagName("incidentid");
// Fill combo with names
for (var i=0; i < objNodeList.length; i++) {
bob.comboResults.options[i]=new Option(objNumberList.item(i).text + ' - ' + objNodeList.item(i).text, objindex.item(i).text);
bob.comboResults.size=i+1;
}
alert(objNodeList.length);
// Delete extra entries
while ( objNodeList.length < bob.comboResults.options.length) {
bob.comboResults.options[(bob.comboResults.options.length - 1)] = null;
}
}//if >3
//else resize and clear
else{
while (bob.comboResults.options.length > 0) {
bob.comboResults.options[0] = null;
bob.comboResults.size=1;
} //else
}
}
this query:
Select * from incident where (upper(description) containing upper('out') and companyid = 9)
gives me this data island:
Code:
<?xml version="1.0"?>
<incidents>
<incident>
<description>Log slipped out of beak and hit car parked in 9 berth parking</description>
<form_no>12</form_no>
<incident_date>17/12/2001</incident_date>
<incidentid>11</incidentid>
</incident>
<incident>
<description>Stack blew out and hit rams of 966</description>
<form_no>24</form_no>
<incident_date>28/02/2002</incident_date>
<incidentid>23</incidentid>
</incident>
<incident>
<description>Wayne Boyd brought to H&S officer attention.
Log rows out side check point are dangerous as it creates to little a turning circle for exiting trucks. Also, if row goes out too far then it prevents trucks entering the gantry to see exiting small vehicles. - This is an incident because it is already listed as hazard.</description>
<form_no>56</form_no>
<incident_date>17/05/2002</incident_date>
<incidentid>64</incidentid>
</incident>
<incident>
<description>Log fell out of head, bounched and damaged brke light and bent hand rail.</description>
<form_no>58</form_no>
<incident_date>10/07/2002</incident_date>
<incidentid>68</incidentid>
</incident>
<incident>
<description>RFH truck took out wall at KEXP lane 3</description>
<form_no>62</form_no>
<incident_date>9/08/2002</incident_date>
<incidentid>74</incidentid>
</incident>
<incident>
<description>Pushing reject log out off bunk. Did not know 2 watersiders bending down marking logs.</description>
<form_no>76</form_no>
<incident_date>27/09/2002</incident_date>
<incidentid>94</incidentid>
</incident>
<incident>
<description>Brian Vernall from Lodestar noticed two drivers and one mechanic walking through the salt store without either any High Viz or helmets during recent cut back operations.
Notified David Fraser during recent meeting held to discuss recent accidents.
David Hone has spoken to employees concerned.</description>
<form_no>79</form_no>
<incident_date>16/10/2002</incident_date>
<incidentid>108</incidentid>
</incident>
<incident>
<description>Area at the debarker is often congested with trucks out of chip area. The is also stacking of logs in front of debarker.</description>
<form_no>82</form_no>
<incident_date>10/10/2002</incident_date>
<incidentid>112</incidentid>
</incident>
<incident>
<description>Coming out of checkpoint and was almost collected by truck.
The rows on corner of CP and Tasman quay were too high and blocked vision of both truck and loader.</description>
<form_no>94</form_no>
<incident_date>3/12/2002</incident_date>
<incidentid>137</incidentid>
</incident>
<incident>
<description>QM truck wheel went into unidentified slip.
Tried to pull out and in doing so hit wagon.
Damage to truck roof.</description>
<form_no>103</form_no>
<incident_date>23/01/2003</incident_date>
<incidentid>147</incidentid>
</incident>
<incident>
<description>Has been seen in yard without PPI</description>
<form_no>107</form_no>
<incident_date>10/02/2003</incident_date>
<incidentid>151</incidentid>
</incident>
<incident>
<description>Loader unloaded truck in unchaining area whilst driver was still unchaining. Log fell out on drivers side damaging truck.</description>
<form_no>109</form_no>
<incident_date>21/02/2003</incident_date>
<incidentid>156</incidentid>
</incident>
<incident>
<description>Debarked log slipped out while loading Row1 11 berth.
Almost hit a car parked in the wrong place.</description>
<form_no>111</form_no>
<incident_date>26/02/2003</incident_date>
<incidentid>158</incidentid>
</incident>
<incident>
<description>Both gentlemen seen scaling logs on 10 berth without their helmets on. The helmets were discarded.</description>
<form_no>113</form_no>
<incident_date>14/03/2003</incident_date>
<incidentid>161</incidentid>
</incident>
<incident>
<description>Ryan was doing pullout in beak when logs slipped out sideways.
Ryan had to dodge logs.</description>
<form_no>117</form_no>
<incident_date>1/04/2003</incident_date>
<incidentid>165</incidentid>
</incident>
<incident>
<description>Tried to cut through Tranzrail not knowing that they were about to shunt. Rake shunted when Carol was climbing up.</description>
<form_no>119</form_no>
<incident_date>7/04/2003</incident_date>
<incidentid>167</incidentid>
</incident>
<incident>
<description>Vehicle (Citroen hatch back OB4155) believed to belong to Tolls employee pulled out of 11berth car park in front of loader. Car almost collected. Drove off. Car later ID as Log Management employee.</description>
<form_no>120</form_no>
<incident_date>1/05/2003</incident_date>
<incidentid>178</incidentid>
</incident>
<incident>
<description>QM992 revrsing loaded out of A Row.
Empty Owens980 shot between QM992 and rail.
QM992 had to brake severly to avoid collision.</description>
<form_no>131</form_no>
<incident_date>26/06/2003</incident_date>
<incidentid>196</incidentid>
</incident>
<incident>
<description>Ginger on 988G reversing loaded out of D5 hit Owens Wagner 100(416) reversing north loaded. Caused damage to stairs and handrail.</description>
<form_no>133</form_no>
<incident_date>7/07/2003</incident_date>
<incidentid>206</incidentid>
</incident>
</incidents>
and yet my select box shows nothing. Most of the time this function is working. a perfect example is if i type "the" into the text box, i get nothing, but if i type "ther" into the text box i get 6 records shown.
I know that 20 records are returned with "the" because the data island is saved with these records in them. however,
Code:
alert(objNodeList.length);
Can anyone tell me why this is not working on some search criteria but is on others???
Tracey
Remember... True happiness is not getting what you want...
Its wanting what you have got!