...

View Full Version : Auto Complete Script



angst
12-19-2005, 03:51 PM
hello,
I found this really kool auto complete script that I want to use to replace my current <select> drop down, but the problem is that because it's jsut an auto complete it doesn't hold the same information that the <select> did.
like adding a value for ID, and other information,

I was using this:



function DisplayDescription(selectIndex) {
var costArray=selectIndex.split("|");
document.firstForm.ProDescription.value = costArray[1];
document.firstForm.ProID.value = costArray[0];
}


to split the data and show the correct information to the user. as well as insert the ID into a hidden field.

so what I'm wondering is if there is a way to use both scripts, or rather, add this split function into the auto complete script.

auto complete code:


<html>
<head>
<style>
.AutoCompleteBackground
{
background-color:white;
}
.AutoCompleteHighlight
{
background-color:#CCCCCC;

}
</style>
<script language=javascript>

function AutoCompleteDB()
{
// set the initial values.
this.bEnd = false;
this.nCount = 0;
this.aStr = new Object;
}

AutoCompleteDB.prototype.add = function(str)
{
// increment the count value.
this.nCount++;

// if at the end of the string, flag this node as an end point.
if ( str == "" )
this.bEnd = true;
else
{
// otherwise, pull the first letter off the string
var letter = str.substring(0,1);
var rest = str.substring(1,str.length);

// and either create a child node for it or reuse an old one.
if ( !this.aStr[letter] ) this.aStr[letter] = new AutoCompleteDB();
this.aStr[letter].add(rest);
}
}

AutoCompleteDB.prototype.getCount = function(str, bExact)
{
// if end of search string, return number
if ( str == "" )
if ( this.bEnd && bExact && (this.nCount == 1) ) return 0;
else return this.nCount;

// otherwise, pull the first letter off the string
var letter = str.substring(0,1);
var rest = str.substring(1,str.length);

// and look for case-insensitive matches
var nCount = 0;
var lLetter = letter.toLowerCase();
if ( this.aStr[lLetter] )
nCount += this.aStr[lLetter].getCount(rest, bExact && (letter == lLetter));

var uLetter = letter.toUpperCase();
if ( this.aStr[uLetter] )
nCount += this.aStr[uLetter].getCount(rest, bExact && (letter == uLetter));

return nCount;
}

AutoCompleteDB.prototype.getStrings = function(str1, str2, outStr)
{
if ( str1 == "" )
{
// add matching strings to the array
if ( this.bEnd )
outStr.push(str2);

// get strings for each child node
for ( var i in this.aStr )
this.aStr[i].getStrings(str1, str2 + i, outStr);
}
else
{
// pull the first letter off the string
var letter = str1.substring(0,1);
var rest = str1.substring(1,str1.length);

// and get the case-insensitive matches.
var lLetter = letter.toLowerCase();
if ( this.aStr[lLetter] )
this.aStr[lLetter].getStrings(rest, str2 + lLetter, outStr);

var uLetter = letter.toUpperCase();
if ( this.aStr[uLetter] )
this.aStr[uLetter].getStrings(rest, str2 + uLetter, outStr);
}
}


function AutoComplete(aStr, oText, oDiv, nMaxSize)
{
// initialize member variables
this.oText = oText;
this.oDiv = oDiv;
this.nMaxSize = nMaxSize;

// preprocess the texts for fast access
this.db = new AutoCompleteDB();
var i, n = aStr.length;
for ( i = 0; i < n; i++ )
{
this.db.add(aStr[i]);
}

// attach handlers to the text-box
oText.AutoComplete = this;
oText.onkeyup = AutoComplete.prototype.onTextChange;
oText.onblur = AutoComplete.prototype.onTextBlur;
}

AutoComplete.prototype.onTextBlur = function()
{
this.AutoComplete.onblur();
}

AutoComplete.prototype.onblur = function()
{
this.oDiv.style.visibility = "hidden";
}

AutoComplete.prototype.onTextChange = function()
{
this.AutoComplete.onchange();
}

AutoComplete.prototype.onDivMouseDown = function()
{
this.AutoComplete.oText.value = this.innerHTML;
}

AutoComplete.prototype.onDivMouseOver = function()
{
this.className = "AutoCompleteHighlight";
}

AutoComplete.prototype.onDivMouseOut = function()
{
this.className = "AutoCompleteBackground";
}

AutoComplete.prototype.onchange = function()
{
var txt = this.oText.value;

// count the number of strings that match the text-box value
var nCount = this.db.getCount(txt, true);

// if a suitable number then show the popup-div
if ( (this.nMaxSize == -1 ) || ((nCount < this.nMaxSize) && (nCount > 0)) )
{
// clear the popup-div.
while ( this.oDiv.hasChildNodes() )
this.oDiv.removeChild(this.oDiv.firstChild);

// get all the matching strings from the AutoCompleteDB
var aStr = new Array();
this.db.getStrings(txt, "", aStr);

// add each string to the popup-div
var i, n = aStr.length;
for ( i = 0; i < n; i++ )
{
var oDiv = document.createElement('div');
this.oDiv.appendChild(oDiv);
oDiv.innerHTML = aStr[i];
oDiv.onmousedown = AutoComplete.prototype.onDivMouseDown;
oDiv.onmouseover = AutoComplete.prototype.onDivMouseOver;
oDiv.onmouseout = AutoComplete.prototype.onDivMouseOut;
oDiv.AutoComplete = this;
}
this.oDiv.style.visibility = "visible";
}
else // hide the popup-div
{
this.oDiv.innerHTML = "";
this.oDiv.style.visibility = "hidden";
}
}

function createAutoComplete()
{
var aNames =
[
"Aaron", "Abbott", "Abdallah", "Abdul", "Abdullah", "Abe", "Abel", "Abiba", "Abie", "Abner", "Abraham", "Abram", "Absalom", "Abu", "Ace", "Ackeem", "Adair", "Adalberto", "Adam", "Adan", "Addison", "Ade", "Adem", "Aderes", "Adie", "Adiel", "Adita", "Adlai", "Adolf", "Adolfo", "Adolph", "Adonia", "Adonis", "Adrian", "Adrien", "Agustin", "Ahmad", "Ahmed", "Aidan", "Aiden", "Airen", "Aislinn", "Aj", "Ajani", "Ajay", "Akeem", "Akil", "Akuji", "Al", "Alain", "Alake", "Alan", "Alaric", "Alastair", "Alban", "Albany", "Albert", "Alberto", "Albeto", "Albin", "Albrecht", "Aldan", "Alden", "Aldo", "Aldon", "Aldora", "Aldous", "Alec", "Alejandro", "Alek", "Aleksander", "Alem", "Alen", "Alev", "Alex", "Alexander", "Alexei", "Alf", "Alfonso", "Alfonzo", "Alfred", "Alfredo", "Alijah", "Alisdair", "Allan", "Allen", "Alonso", "Alonzo", "Aloysius", "Alphonse", "Alphonso", "Alton", "Alva", "Alvaro", "Alvin", "Amadeo", "Amadeus", "Amado", "Amador", "Amalia", "Amalie", "Aman", "Amana", "Amandla", "Amari", "Ambrose", "America", "Americo", "Amerigo", "Amir", "Amiri", "Ammon", "Amon", "Amos", "Anana", "Ananda", "Anando", "Anaru", "Anastasios", "Anatole", "Anatoliy", "Ande", "Anderson", "Andre", "Andreas", "Andrej", "Andres", "Andrew", "Andy", "Anemone", "Anfernee", "Angelo", "Angus", "Anil", "Anin", "Anlon", "Anselm", "Anselmo", "Anson", "Antal", "Anthony", "Anton", "Antonio", "Anwar", "Aoko", "Apollo", "Aquil", "Aquila", "Aquilla", "Ara", "Aram", "Aramis", "Archer", "Archibald", "Archie", "Archy", "Arden", "Aric", "Aries", "Aristotelis", "Aristotle", "Ariza", "Arlan", "Arlen", "Arlo", "Arman", "Armand", "Armande", "Armando", "Armen", "Armin", "Armon", "Armondo", "Arnaud", "Arne", "Arnie", "Arnold", "Aron", "Arran", "Arron", "Art", "Artemis", "Arthur", "Artie", "Arty", "Arva", "Arvid", "Asa", "Asabi", "Asalie", "Asher", "Ashton", "Asis", "Asli", "Athalia", "Athanasius", "Athelstan", "Athelston", "Athol", "Atwell", "August", "Augustin", "Augustine", "Augustus", "Austin", "Avary", "Averil", "Averill", "Avery", "Avi", "Avongara", "Avram", "Ayame", "Ayoka", "Azelin", "Azize", "Azuka", "Azuriah",
"Bahari", "Baird", "Bairn", "Baldwin", "Ballard", "Balthazar", "Banji", "Baptist", "Barak", "Barke", "Barnabas", "Barnabus", "Barnaby", "Barnard", "Barnett", "Barney", "Barny", "Baron", "Barrett", "Barry", "Bart", "Barth", "Bartholomew", "Barton", "Baruch", "Bary", "Bash", "Basil", "Bast", "Bastian", "Baxter", "Bayard", "Beat", "Beaty", "Beau", "Beauregard", "Beck", "Belay", "Belio", "Bell", "Bellamy", "Ben", "Benedict", "Benen", "Benito", "Benjamin", "Benjy", "Bennet", "Bennett", "Bennie", "Benny", "Benson", "Bentley", "Benton", "Berger", "Berke", "Berman", "Bern", "Bernard", "Berne", "Bernie", "Berny", "Bert", "Bertram", "Bertrand", "Bevan", "Beven", "Bevin", "Beyla", "Bidelia", "Bijean", "Bikita", "Bilen", "Bill", "Billy", "Bin", "Bina", "Bing", "Birch", "Bishop", "Biton", "Bjorn", "Blaine", "Blair", "Blaise", "Blake", "Blane", "Bliss", "Blythe", "Bo", "Bob", "Bobby", "Boden", "Bonaventure", "Bond", "Boniface", "Bonifacio", "Bono", "Boone", "Boris", "Bowen", "Bowie", "Brad", "Braden", "Bradford", "Bradley", "Bradshaw", "Brady", "Braeden", "Braedon", "Braima", "Braithe", "Bran", "Brand", "Branden", "Brandon", "Brant", "Braxton", "Brayden", "Brazil", "Brend", "Brendan", "Brendon", "Brendyn", "Brennan", "Brennon", "Brent", "Brenton", "Bret", "Brett", "Brewster", "Brian", "Briar", "Brice", "Brick", "Brighton", "Brilane", "Britt", "Britton", "Brock", "Broderick", "Brodie", "Brody", "Brogan", "Brone", "Bronson", "Brook", "Brooks", "Bruce", "Bruno", "Bryan", "Bryant", "Bryce", "Bryceton", "Bryn", "Brynn", "Bryon", "Bryson", "Bubba", "Buck", "Bud", "Buddie", "Buddy", "Buford", "Burgess", "Burke", "Burt", "Burton", "Buster", "Butch", "Butcher", "Butchie", "Byrne", "Byron",
"Caddall", "Cade", "Cadell", "Caden", "Cael", "Caelan", "Caesar", "Cahal", "Cain", "Caine", "Cal", "Caleb", "Callum", "Calum", "Calvin", "Cam", "Camden", "Cameron", "Camlin", "Campbell", "Camron", "Carl", "Carleton", "Carlisle", "Carlo", "Carlos", "Carlton", "Carlyle", "Carmac", "Carmelo", "Carmine", "Carr", "Carrick", "Carson", "Carsten", "Carsyn", "Carter", "Carver", "Cary", "Cash", "Cashley", "Casimir", "Caspar", "Casper", "Caspian", "Cassius", "Cathal", "Cavan", "Cecil", "Cedric", "Cesar", "Chad", "Chance", "Chancellor", "Chandler", "Channing", "Chante", "Chantry", "Charl", "Charles", "Charli", "Charlie", "Charls", "Charlton", "Chars", "Chas", "Chase", "Chauncey", "Chaz", "Cheche", "Chen", "Chesley", "Chester", "Chet", "Cheyne", "Chick", "Chico", "Chill", "Chilton", "Chimelu", "Chip", "Chipo", "Chris", "Chrissy", "Christel", "Christof", "Christoph", "Christopher", "Chuck", "Cian", "Cicero", "Clancey", "Clancy", "Clarence", "Clark", "Clarke", "Claude", "Claudio", "Claus", "Clay", "Clayland", "Clayton", "Cleavant", "Cleave", "Cleavon", "Clem", "Clemens", "Clement", "Clemente", "Cliff", "Clifford", "Clifton", "Clint", "Clinton", "Clive", "Clove", "Clover", "Clovis", "Clyde", "Cobi", "Cocheta", "Cody", "Colbert", "Cole", "Coleman", "Coley", "Colin", "Collin", "Colm", "Colman", "Colt", "Colte", "Coltin", "Colton", "Columbia", "Columbine", "Columbus", "Comfort", "Conal", "Conall", "Conan", "Conell", "Conlan", "Conner", "Connor", "Conor", "Conrad", "Constantine", "Content", "Conway", "Cooper", "Corbin", "Cord", "Cordeiro", "Cordel", "Cordell", "Cordero", "Corey", "Corliss", "Cornelia", "Cornelis", "Cornelius", "Cornell", "Cort", "Corwin", "Cory", "Cosima", "Cosmo", "Coty", "Coy", "Coye", "Coyle", "Craig", "Creighton", "Crevan", "Criostoir", "Cristian", "Cristophe", "Crockett", "Cullen", "Curry", "Curt", "Curtis", "Cy", "Cyd", "Cyril", "Cyrus",
"Dafydd", "Dagan", "Dahlia", "Dain", "Dakarai", "Dakoda", "Dakota", "Dallin", "Dalton", "Dalziel", "Damario", "Damarius", "Damian", "Damien", "Damion", "Damon", "Dan", "Dane", "Daniel", "Danil", "Danilo", "Danny", "Dante", "Danton", "Daray", "Darby", "Darcey", "Darcie", "Darcy", "Dard", "Daren", "Dareo", "Darian", "Darien", "Darin", "Dario", "Darious", "Darius", "Darnell", "Darrell", "Darren", "Darrin", "Darrius", "Darron", "Darryl", "Darshan", "Daryl", "Daryn", "Dasan", "Dashiell", "Dathan", "Davaid", "Davan", "Dave", "David", "Davin", "Davis", "Davu", "Dawson", "Dax", "Dayton", "Deacon", "Dean", "Dearl", "Declan", "Dedric", "Dedrick", "Del", "Delaney", "Delano", "Delbert", "Delvan", "Delvin", "Dembe", "Demetri", "Demetrius", "Demian", "Demitrius", "Dempsey", "Denis", "Dennis", "Denny", "Denver", "Denzel", "Deo", "Derek", "Derex", "Dermot", "Derora", "Derreck", "Derrell", "Derrick", "Des", "Desdemona", "Desmond", "Devaki", "Devan", "Deven", "Devin", "Devlan", "Devlin", "Devon", "Dewey", "Dewitt", "Dexter", "Diallo", "Diarmuid", "Diata", "Dick", "Dickson", "Diederick", "Diego", "Dieter", "Dillan", "Dillian", "Dillon", "Dimitri", "Dino", "Dion", "Dionysius", "Dionysus", "Dirc", "Dirk", "Dixon", "Dmitri", "Dmyphnah", "Doane", "Doctor", "Dolan", "Dolin", "Dolph", "Dom", "Domenic", "Domenica", "Dominic", "Dominick", "Dominy", "Don", "Donal", "Donald", "Donard", "Donato", "Donnell", "Donny", "Donovan", "Dontae", "Dorcey", "Dorset", "Dorsey", "Doug", "Dougal", "Douglas", "Douglass", "Doyle", "Doyt", "Drake", "Drew", "Dru", "Duane", "Dudley", "Duena", "Duff", "Duffie", "Dugan", "Duka", "Duke", "Dumi", "Duncan", "Dunixi", "Dunn", "Dunne", "Dustan", "Dustin", "Duston", "Dusty", "Dwayne", "Dwight", "Dylan", "Dylon", "Dyre",
"Maarten", "Maat", "Mac", "Macha", "Mack", "Mackenzie", "Macklin", "Macon", "Maddox", "Magee", "Magnus", "Maha", "Mahari", "Mahdi", "Mahyar", "Maitland", "Major", "Makalo", "Makenna", "Malachi", "Malachy", "Malaika", "Malcolm", "Malik", "Malomo", "Malone", "Mandel", "Manica", "Manning", "Manny", "Manolatos", "Mansa", "Manuel", "Marc", "Marcel", "Marcello", "Marcellus", "Marco", "Marcos", "Marcus", "Mariatu", "Marin", "Marino", "Mario", "Mark", "Marka", "Marko", "Markus", "Marley", "Marlow", "Maro", "Marques", "Marquis", "Marshall", "Martel", "Martell", "Martin", "Marty", "Marv", "Marvene", "Marvin", "Masada", "Maselyn", "Maslin", "Mason", "Mateo", "Mathieu", "Matt", "Matteo", "Matthew", "Matthias", "Mattox", "Mauli", "Maulo", "Maurice", "Maurilio", "Maverick", "Max", "Maxim", "Maxime", "Maximilian", "Maximillian", "Maximillion", "Maxwell", "Mayes", "Maynard", "Mckale", "Mckenzie", "Mea", "Medard", "Meelao", "Meged", "Meier", "Meir", "Melchior", "Melora", "Melva", "Melvin", "Melvyn", "Mendel", "Menora", "Mercer", "Mercury", "Meria", "Merle", "Merlin", "Merrill", "Merv", "Mervin", "Mervyn", "Meryl", "Meryle", "Messina", "Meyer", "Micah", "Michael", "Micheal", "Michel", "Michiel", "Mick", "Mickey", "Miguel", "Mika", "Mikaili", "Mike", "Mikel", "Mikhail", "Milandu", "Miles", "Miller", "Mills", "Milo", "Milson", "Milt", "Milton", "Mircea", "Miroslav", "Mirza", "Misae", "Misha", "Mitch", "Mitchel", "Mitchell", "Miyanda", "Mizell", "Mohamad", "Mohammed", "Moke", "Monahan", "Monroe", "Montague", "Montana", "Monte", "Montego", "Montgomery", "Monty", "Morathi", "Mordecai", "More", "Morey", "Morgen", "Morley", "Morrie", "Morris", "Morrison", "Morse", "Mort", "Mortimer", "Morton", "Morty", "Moses", "Moshe", "Moss", "Moya", "Muhammad", "Muhammed", "Muna", "Murphy", "Murray", "Musoke", "Mutia", "Mycroft", "Mykal", "Myles", "Myron","Packard", "Paco", "Padraic", "Paley", "Palti", "Pancho", "Panfila", "Paolo", "Paris", "Parker", "Parkin", "Parlan", "Parley", "Parrish", "Parry", "Parson", "Pascal", "Pascale", "Pascha", "Pasi", "Patrick", "Patton", "Paul", "Pauline", "Paulo", "Paulos", "Pax", "Paxton", "Payton", "Peale", "Pedro", "Pelham", "Pembroke", "Penn", "Pepe", "Percival", "Percy", "Peregrine", "Perrin", "Perry", "Peta", "Pete", "Peter", "Petrus", "Peyton", "Phelan", "Phemia", "Phiala", "Phil", "Phila", "Philip", "Phillip", "Phoenix", "Pierce", "Pierre", "Pieter", "Pirro", "Placido", "Platt", "Ponce", "Porter", "Potter", "Prakash", "Prentice", "Prescott", "Preston", "Price", "Primo", "Primoz", "Prince", "Princeton",
"Quentin", "Quenton", "Quillan", "Quimby", "Quincey", "Quincy", "Quinlan", "Quinn", "Quinta", "Quintin",
"Tad", "Tai", "Takeya", "Talbot", "Tallulah", "Talon", "Tamid", "Tamzen", "Tanner", "Tarance", "Tarek", "Tarrance", "Tavis", "Tavish", "Taylor", "Taz", "Ted", "Teman", "Temani", "Tempest", "Temple", "Terence", "Terrell", "Terrence", "Tevye", "Thaddeus", "Than", "Thaniel", "Thayne", "Theo", "Theobald", "Theodore", "Theodoric", "Theophilus", "Theron", "Thom", "Thomas", "Thomson", "Thor", "Thorburn", "Thorin", "Thorstan", "Thorsten", "Thorston", "Thurston", "Tiago", "Tibor", "Tierry", "Tiger", "Tim", "Timeus", "Timon", "Timothy", "Tito", "Titus", "Tivoli", "Toal", "Tobias", "Toby", "Todd", "Tom", "Tommy", "Tony", "Tor", "Torin", "Torleif", "Torsten", "Trace", "Tranter", "Travis", "Trayc", "Tre", "Trefor", "Tremaine", "Tremayne", "Trent", "Trenton", "Trever", "Trevis", "Trevor", "Trey", "Trinidad", "Tristan", "Tristen", "Tristram", "Troy", "Truman", "Tuan", "Tucker", "Tulio", "Tully", "Turner", "Twain", "Ty", "Tye", "Tyler", "Tylor", "Tym", "Tyree", "Tyrel", "Tyrell", "Tyrese", "Tyrone", "Tysen", "Tyson",
"Ugo", "Uilliam", "Uland", "Ulandus", "Ulf", "Ulises", "Ulliem", "Ulric", "Ulrich", "Ultan", "Ulysses", "Umberto", "Uri", "Uriah", "Uriel", "Urien", "Ushma", "Uthman",
"Valdemar", "Valente", "Valentine", "Vallis", "Van", "Vance", "Vander", "Vandyke", "Vani", "Vasilios", "Vasilis", "Vaughan", "Vaughn", "Vern", "Vernon", "Victor", "Victori", "Vilmar", "Vinal", "Vincent", "Vinson", "Virgil", "Virgilio", "Vivek", "Vladilen", "Vladimir", "Vladislav", "Volker", "Volodymyr", "Vulcan",
"Wade", "Waldo", "Walker", "Wallace", "Wally", "Walter", "Walton", "Waltraud", "Wang", "Warren", "Washington", "Wayman", "Waymon", "Waymond", "Wayne", "Wendell", "Werner", "Wes", "Wesley", "Westin", "Westney", "Weston", "Whitfield", "Wil", "Wilbur", "Wiley", "Wilfred", "Wilfrid", "Wilfried", "Wilhelm", "Wilhelmien", "Will", "Willard", "Willem", "William", "Willie", "Willis", "Wilmer", "Wilmot", "Wilson", "Winifred", "Winston", "Winthrop", "Wolf", "Wolfe", "Wolff", "Wolffe", "Wolfgang", "Wolfram", "Woodrow", "Woody", "Wright", "Wyatt", "Wyeth",
"Xander", "Xavier", "Xylon",
"Yakov", "Yan", "Yann", "Yannic", "Yannis", "Yari", "Yasir", "Yasser", "Yevgeniy", "Yevgenyi", "Yitzhak", "Yong", "York", "Yoshi", "Yuri", "Yuriy", "Yves",
"Zach", "Zachariah", "Zachary", "Zachery", "Zack", "Zackary", "Zaid", "Zandy", "Zane", "Zavier", "Zayd", "Zeb", "Zebadiah", "Zebulon", "Zedekiah", "Zeke", "Zen", "Zeno", "Zenon", "Zephyr", "Ziggy", "Zimraan", "Zuriel"
];
new AutoComplete(
aNames,
document.getElementById('theText'),
document.getElementById('theDiv'),
25
);
}

</script>
</head>
<body onload="document.getElementById('theText').focus(); createAutoComplete();">
<form name=fred action="AutoComplete.html" method=post>
<div style="position:relative;overflow:visible">
<input name=theText id="theText" type=text autocomplete=on>
<div id="theDiv" style="position:absolute;left:0px;top:21px;visibility:hidden;border:solid black 1px;background-color:white;z-index:1;font-family: Verdana;font-size: 11px;"></div>
</div>
</form>
</body>
</html>



would like to do something like:

56|Aaron|Male from Canada

but of course only actually show the name Aaron in the auto complete field.

any ideas?

thanks in advance for your time!!!

-Ken

Ancora
12-19-2005, 04:38 PM
.....

angst
12-19-2005, 05:11 PM
hmm, that scripts not working at all for me,
but it's not really what I'm looking for either. the current script is nice,
all I want to do is split up the data, and when a selection is made, have the different split items appear if different fields. can this be done with the current script? sorry, javascript coding is still very new to me.

thanks again for your time!
-Ken

angst
12-19-2005, 05:37 PM
.....

angst
12-19-2005, 05:48 PM
ok,
I'm now tring to use this autocomplete script, much simpler code, but I'm still having trouble getting it to split.

my code


<script language=javascript>

function autoComplete (field, select, property, forcematch) {

var found = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
found=true; break;
}
}
if (found) { select.selectedIndex = i; }
else { select.selectedIndex = -1; }
if (field.createTextRange) {
if (forcematch && !found) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found ? select.options[i][property] : oldValue;
if (newValue != field.value) {
field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart('character', oldValue.length) ;
rNew.select();
}
}
}
}

</script>

<FORM>

<B>Auto-Complete</B><BR>
Start typing a name in the input box that matches a name in the drop-down...<BR>
<INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)">
<SELECT NAME="options"
onChange="this.form.input1.value=this.options[this.selectedIndex].value">
<OPTION VALUE="1|Toronto|adam">adam
<OPTION VALUE="2|New York|george">george
<OPTION VALUE="3|North Bay|matt">matt
<OPTION VALUE="4|Hamilton|bill">bill
<OPTION VALUE="5|Barrie|greg">greg
<OPTION VALUE="6|Mississaga|bob">bob
<OPTION VALUE="7|Burlington|david">david
<OPTION VALUE="8|New Market|ryan">ryan
</SELECT>

</FORM>


what I'm trying to do it have the first and second values of the string inserted into they're own hidden text inputs, but no luck as of yet.

thanks again for your time.

-Ken



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum