Hi,
I'm a VBScripter rather than a JavaScripter and I am stuggling on changing some GPL code to do what I need.
In my HTA, when I type in a text box it has a little dropdown that makes suggestions based on an array.
The original code can be found here.
The original code lists US states in an array, but I am trying to use an ADODB connection to pull the SiteName details from an Access database (I use this elsewhere in the script) using a System DSN connection. I've got it to connect to the database ok, but I now need to get it to iterate through the database. This is where I am thrown by JS :-(.
Here is the original array:
And here is my attempt:
I think I may need to put the database records into an array within the function?
The alert return the last record and when I type in the text box I get:
As always, I am very grateful for any help or pointers.
Many thanks
Tex
I'm a VBScripter rather than a JavaScripter and I am stuggling on changing some GPL code to do what I need.
In my HTA, when I type in a text box it has a little dropdown that makes suggestions based on an array.
The original code can be found here.
The original code lists US states in an array, but I am trying to use an ADODB connection to pull the SiteName details from an Access database (I use this elsewhere in the script) using a System DSN connection. I've got it to connect to the database ok, but I now need to get it to iterate through the database. This is where I am thrown by JS :-(.
Here is the original array:
Code:
function StateSuggestions() {
StateSuggestionsDB
this.states = [
"Albion House", "Pembroke House", "Peppie Close", "Arkansas",
"California", "Colorado", "Connecticut",
"Delaware", "Florida", "Georgia", "Hawaii",
"Idaho", "Illinois", "Indiana", "Iowa",
"Kansas","blar blar blar..."];
}
And here is my attempt:
Code:
function StateSuggestions(){
adOpenForwardOnly = 0;
adLockReadOnly = 1;
adCmdText = 1;
var myConnect = "DSN=SiteDSN";
var ConnectObj = new ActiveXObject("ADODB.Connection");
var adoRecordSet = new ActiveXObject("ADODB.Recordset");
var sql = "SELECT SiteName FROM tblSite;";
ConnectObj.Open(myConnect);
adoRecordSet.Open(sql, ConnectObj, adOpenForwardOnly,adLockReadOnly,adCmdText);
alert ("recordCount: " + adoRecordSet("SiteName").value);
this.states = adoRecordSet("SiteName").value;
adoRecordSet.Close()
}
I think I may need to put the database records into an array within the function?
The alert return the last record and when I type in the text box I get:
Code:
Error: 'this.states[...]' is null or not an object
As always, I am very grateful for any help or pointers.
Many thanks
Tex