|
| |
|
|
mkemper
Posts: 6 Joined: 5/25/2004 Status: offline
|
self populating drop down trouble Please Help - 5/25/2004 10:56:35
I need a self populating dropdown menu that populates by character refinement. Like the outlook address book search, you type a and it lists all the people that begin with a you type al and it lists all the people that begin with al. That is the type of query I need for a sql database through a dreamweaver MX webpage. I've tried to get this for the last work week on my own and keep falling short. If anyone has the code I would greatly appreciate it.
|
|
|
|
BeTheBall
Posts: 6502 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 11:39:28
Welcome to Outfront. This does exactly what you want: http://authors.aspalliance.com/thycotic/articles/view.aspx?id=3 Just put this in the <head> section of your page: <script language="JavaScript" type="text/javascript">
function keySort(dropdownlist,caseSensitive) {
// check the keypressBuffer attribute is defined on the dropdownlist
var undefined;
if (dropdownlist.keypressBuffer == undefined) {
dropdownlist.keypressBuffer = '';
}
// get the key that was pressed
var key = String.fromCharCode(window.event.keyCode);
dropdownlist.keypressBuffer += key;
if (!caseSensitive) {
// convert buffer to lowercase
dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();
}
// find if it is the start of any of the options
var optionsLength = dropdownlist.options.length;
for (var n=0; n < optionsLength; n++) {
var optionText = dropdownlist.options[n].text;
if (!caseSensitive) {
optionText = optionText.toLowerCase();
}
if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) {
dropdownlist.selectedIndex = n;
return false; // cancel the default behavior since
// we have selected our own value
}
}
// reset initial key to be inline with default behavior
dropdownlist.keypressBuffer = key;
return true; // give default behavior
}
</script>
Then add the onkeypress event to the select tag, something like this: <select NAME="MyDropDown" SIZE="1" onkeypress="return keySort(this);">
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
mkemper
Posts: 6 Joined: 5/25/2004 Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 11:59:39
Thanks for the info and the welcome. Does this work for ASP VBscript?... My apologies I am kinda new to website design and such. I got thrown into by my boss from more of an infrastructure position. So needless to say I am almost completely out of my realm. Any helpful hints for happy campers would be greatly appreciated. Thanks again. Mike quote:
<script language="JavaScript" type="text/javascript"> function keySort(dropdownlist,caseSensitive) { // check the keypressBuffer attribute is defined on the dropdownlist var undefined; if (dropdownlist.keypressBuffer == undefined) { dropdownlist.keypressBuffer = ''; } // get the key that was pressed var key = String.fromCharCode(window.event.keyCode); dropdownlist.keypressBuffer += key; if (!caseSensitive) { // convert buffer to lowercase dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase(); } // find if it is the start of any of the options var optionsLength = dropdownlist.options.length; for (var n=0; n < optionsLength; n++) { var optionText = dropdownlist.options[n].text; if (!caseSensitive) { optionText = optionText.toLowerCase(); } if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { dropdownlist.selectedIndex = n; return false; // cancel the default behavior since // we have selected our own value } } // reset initial key to be inline with default behavior dropdownlist.keypressBuffer = key; return true; // give default behavior
|
|
|
|
BeTheBall
Posts: 6502 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 12:04:14
quote:
Does this work for ASP VBscript?... Yes. I tested it on a dropdown that was being populated from a table in my db with ASP.
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
mkemper
Posts: 6 Joined: 5/25/2004 Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 15:07:29
I'm having problems with the code. Sorry I am kind of a newbie. Are any details you could give me.. That I might be missing. thanks again mike
|
|
|
|
BeTheBall
Posts: 6502 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 15:54:04
Maybe I assumed too much. I thought you already had the dropdown and you just needed the part that would allow the choice to narrow as you typed. Is that not correct? Do you not have the dropdown part? I have never used DreamWeaver so can't be of much help on that part of the project.
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
BeTheBall
Posts: 6502 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 17:05:27
So is the page functioning? Meaning, when the page loads is the dropdown populated with the values from the database?
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
mkemper
Posts: 6 Joined: 5/25/2004 Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 17:22:54
no..the code I sent you doesn't have the dynamic data added...that is another issue ..It comes up without the dyamic code but as soon as I put it to dynamic it won't come up. This thing is killing me. The page itself works with just a text box and a submit button but the text has to be exactly the same as the value in the field. thanks.
|
|
|
|
BeTheBall
Posts: 6502 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: self populating drop down trouble Please Help - 5/25/2004 18:29:22
What is the name of the db field that is supposed to populate the dropdown? What table does it come from?
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
mkemper
Posts: 6 Joined: 5/25/2004 Status: offline
|
RE: self populating drop down trouble Please Help - 5/26/2004 13:48:28
The cell name is item_no and the db is IMINVLOC_SQL. Thanks, Mike
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|