navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

self populating drop down trouble Please Help

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> self populating drop down trouble Please Help
Page: [1]
 
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: 6362
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.

(in reply to mkemper)
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

(in reply to BeTheBall)
BeTheBall

 

Posts: 6362
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.

(in reply to mkemper)
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

(in reply to BeTheBall)
BeTheBall

 

Posts: 6362
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.

(in reply to mkemper)
mkemper

 

Posts: 6
Joined: 5/25/2004
Status: offline

 
RE: self populating drop down trouble Please Help - 5/25/2004 16:32:41   
I have the drop down part but not sure where to add the rest since I have no SQL experience at all... Maybe it is easier to show you what I have thus far since you know already what I want it to do...here it is.............

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connBKdata.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>index.asp</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style2 {font-size: xx-large; font-weight: bold; color: #000000; font-family: Arial, Helvetica, sans-serif;}
-->
</style>
</head>

<body>
<div align="center">
<p class="style2">BK stock status</p>
<p><img src="images/022.jpg" width="143" height="143"></p>
<p align="center">Please enter item number and click submit. </p>
<div align="center">
<fieldset>
<legend> </legend>
</fieldset>
</div>
</div>
<form action="front.asp" method="get" name="frmfront">

<div align="center">
<input name="txtItem" type="text" value="">
<select name="select">
</select>
<input name="SEARCH" type="submit" id="SEARCH" value="SEARCH">
</div>
</form>
</body>
</html>
<%
Dim rsBKdata
Dim rsBKdata_numRows

Set rsBKdata = Server.CreateObject("ADODB.Recordset")
rsBKdata.ActiveConnection = MM_connBKdata_STRING
rsBKdata.Source = "SELECT * FROM dbo.IMINVLOC_SQL WHERE item_no = '" & trim(Request.QueryString("txtItem")) & "' AND loc = 'OD'"
rsBKdata.CursorType = 0
rsBKdata.CursorLocation = 2
rsBKdata.LockType = 1
rsBKdata.Open()

rsBKdata_numRows = 0
%>
<table width="100%" border="1" cellpadding="1" cellspacing="1">
<tr>
<td width="25% "align="center">ITEM NO</td>
<td width="25% "align="center">QTY ON HAND</td>
<td width="25% "align="center">QTY ALLOCATED</td>
<td width="25% "align="center">QTY BACKORDERED</td>
</tr>
<%
while not rsBKdata.EOF %>
<table width="100%" height="100%" border="1" cellpadding="1" cellspacing="0" bgcolor="#D5DEF2">
<tr>
<td width="25% "align="center"><%response.Write rsBKdata.Fields("item_no")%></td>
<td width="25% "align="center"><%response.Write rsBKdata.Fields("qty_on_hand")%></td>
<td width="25% "align="center"><%response.Write rsBKdata.Fields("qty_allocated")%></td>
<td width="25% "align="center"><%response.Write rsBKdata.Fields("qty_bkord")%></td>
</tr>
</table>
<%

rsBKdata.MoveNext
wend


%>

<%
rsBKdata.Close()
Set rsBKdata = Nothing
%>

.....................................

the whole page is right there..thanks again

Mike (The Advil King) LOL:)

(in reply to BeTheBall)
BeTheBall

 

Posts: 6362
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.

(in reply to mkemper)
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.

(in reply to BeTheBall)
BeTheBall

 

Posts: 6362
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.

(in reply to mkemper)
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

(in reply to BeTheBall)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> self populating drop down trouble Please Help
Page: [1]
Jump to: 1





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