Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2004, 12:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select employee name spelling

How can search (select) the name from the dropdown list by pressing employee name spelling ?

I use following coding (dropdown) in the asp page, records retrieve from the SQL Server.
in the dropdown list it display the name alphabetical order.
I want to select the name PETERSEN.

when I press P cursor move to first record of P and when I press E then cursor move (jump) to first record of E.

how can name could be select, when I press P and then E and T , E, R , S, E, N cursor should be
move (jump) to PETERSEN ?

how can do it, what changing in the following code (select option) ?
I want that when I press employee name spelling, cursor should be move (jump) to that employee name ?


<TR>
    <TD>Employee Name</TD>
    <TD><SELECT id=ename name=ename><OPTION selected value="">Select Employee</OPTION>

 <%

set cn=server.CreateObject("adodb.connection")
cn.ConnectionString=".... " // connection string
cn.Open

ssql="select ename from employees order by ename"

set rs=cn.Execute(ssql)
do while rs.eof=false
Response.Write("<option value='" & rs("ename") & "'>")
Response.Write(rs("ename") )
rs.movenext
loop
%>
    </SELECT></TD></TR>

Please help.

Mateen



 
Old May 8th, 2004, 12:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't think you can achieve that, but always when pressed the first letter, the selction jumps to the list item starting with that letter pressed. But typing the other letters in a row doesn't help getting there. I am not sure, if someone could come up with a solution to this. But as far as I have seen, I dont think one can do that.

Anyways, I will keep you posted, if I find something related to that.

Cheers!

-Vijay G
 
Old May 8th, 2004, 12:45 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

By default, select lists don't have this behavior. However, with a bit of JavaScript, you can create your own solution for this. Take a look at the following articles:

http://msdn.microsoft.com/library/en...elect-code.asp
http://webfx.eae.net/dhtml/combobox/combobox.htm
http://p2p.wrox.com/archive/beginnin...2002-10/76.asp


Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 9th, 2004, 11:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your response.

I visit the following site.
but this article don't have this behavior. this behavior like
IE default. it move to first record of press character.

I am trying to solve the problem by the help of these articles.
any other site with related to my problem please
post the site address.

Regards.

Mateen




Quote:
quote:Originally posted by Imar
 By default, select lists don't have this behavior. However, with a bit of JavaScript, you can create your own solution for this. Take a look at the following articles:

http://msdn.microsoft.com/library/en...elect-code.asp
http://webfx.eae.net/dhtml/combobox/combobox.htm
http://p2p.wrox.com/archive/beginnin...2002-10/76.asp


Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 10th, 2004, 02:27 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Does it? How did you see the default behavior? For the first link, did you copy and paste the code for Select.htc to a separate file and save that in the same folder as Select.htm? You'll need two files for the code to work.

For the second link, did you try out the Demo page? It works for me, although it only works in IE.

Finally, you could take a look at the ComboBox control from this site: http://www.metabuilders.com/
It's an ASP.NET control, but by looking at the source, you can easily extract the important JavaScript bits for your own project.

What browsers do you need to support?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 26th, 2004, 03:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your response and site address.

I try, but could not success.
I also try the demo.

I am using internet explorer 6.0

you may like to give one exmple of dropdown (combobox)
how can use with the following asp select coding..

<TR>
    <TD>Employee Name</TD>
    <TD><SELECT id=name name=empno><OPTION selected value="">Select Employee</OPTION>
    <%
dim ssql
set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="" // connection string
cn.Open

ssql="select name from employees order by name"

set rs=cn.Execute(ssql)

do while rs.eof=false
Response.Write("<option value='" & rs("name") & "'>")
Response.Write(rs("name") )
rs.movenext
loop
%>
    </SELECT></TD></TR>


when press employee name it move (jamp) to employee name ?

how can move the rs("name") in the combobox ?

<script>
dm=new ComboBox("dm")
dm.add(
       new ComboBoxItem("",1),
       new ComboBoxItem("benluc",2),
       new ComboBoxItem("benlieeeeck",3),
       new ComboBoxItem("taco",4)
      )
</script>


regards.

Mateen



Quote:
quote:Originally posted by Imar
 Does it? How did you see the default behavior? For the first link, did you copy and paste the code for Select.htc to a separate file and save that in the same folder as Select.htm? You'll need two files for the code to work.

For the second link, did you try out the Demo page? It works for me, although it only works in IE.

Finally, you could take a look at the ComboBox control from this site: http://www.metabuilders.com/
It's an ASP.NET control, but by looking at the source, you can easily extract the important JavaScript bits for your own project.

What browsers do you need to support?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 26th, 2004, 06:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If the demo page of the second link doesn't work, then I am out of ideas. It works for me, so your browser must be broken.

If you look at the source, you'll see it's pretty easy to define your items. The example uses hardcoded values but it would be easy to replace them with server side generated options from a recordset.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 27th, 2004, 01:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your response.

I define item (name) in combobox but it does not accept more then
four items.
secondly hardcoded values how can replace them with the server side
generated options from a recordset ?

<script src="ComboBox.js"></script>

<script>

dm=new ComboBox("dm")

dm.add(
       new ComboBoxItem("Mateen",1),
       new ComboBoxItem("Martin",2),
       new ComboBoxItem("Peter",3),
       new ComboBoxItem("Jones",4)


      )
</script>

combobox can be defined following select list (dropdown) or
select list can be defined in combobox ?
<TR>
    <TD>Employee Name</TD>
    <TD><SELECT id=ename name=empno><OPTION selected value="">Select Employee</OPTION>
    <%

ssql="select ename from employees order by ename"
set rs=cn.Execute(ssql)
do while rs.eof=false
Response.Write("<option value='" & rs("ename") & "'>")
Response.Write(rs("ename") )
rs.movenext
loop
%>
    </SELECT></TD></TR>


any one example please ?

regards.

Mateen

Quote:
quote:Originally posted by Imar
 If the demo page of the second link doesn't work, then I am out of ideas. It works for me, so your browser must be broken.

If you look at the source, you'll see it's pretty easy to define your items. The example uses hardcoded values but it would be easy to replace them with server side generated options from a recordset.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 27th, 2004, 01:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

With a little bit of imagination, this shouldn't be too hard to figure out.
Instead ot writing out the <select> once, you write out: dm.add(

And instead of each <option> element, you write out: new ComboBoxItem("Mateen",1),

and finally, instead of </select>, you write out: )

This way, you loop through your recordset and dump each record into a new ComboBoxItem.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 30th, 2004, 03:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your response.
your coding (combobox)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>ComboBox Demo</title>

<style>
body {font-size:9pt;font-family:verdana;}
button {cursor:hand;border:1px solid black;font-family:arial;font-size:9pt;}
a {color:red;}
a:hover {color:blue}
</style>

</head>

<body>
<script src="ComboBox.js"></script>

<script>

dm=new ComboBox("dm")

dm.add(new ComboBoxItem("Mateen",1),
       new ComboBoxItem("Khan",2),
       new ComboBoxItem("Martin",3),
       new ComboBoxItem("Rose",4)


      )

</script>

<br><br><br>

// I try like this.

<table border="1" bordercolor="black" cellspacing="0" cellpadding="0" width="60%">

  <TR>
    <TD>Employee Name</TD>
    <TD>dm.add(new ComboBoxItem("Mateen",1),
               new ComboBoxItem("Khan",2),
               new ComboBoxItem("Martin",3),
               new ComboBoxItem("Rose",4)

    <%
dim ssql
set cn=server.CreateObject("adodb.connection")
cn.ConnectionString="" // connection string
cn.Open

ssql="select name from employees order by name"

set rs=cn.Execute(ssql)

do while rs.eof=false

// How can use combobox within loop ?

rs.movenext
loop
%>
    )</TD></TR>
    </table><br>

<button hidefocus onClick="alert(dm.value)" id=button1 name=button1>Show Value</button>&nbsp;
<button hidefocus onClick="dm.add(new ComboBoxItem(window.prompt('Type in the text to add',''),window.prompt('Type in a value to add','')))" id=button2 name=button2>Add Item</button>&nbsp;
<button hidefocus onClick="dm.remove(window.prompt('Type in an index to remove',''))"
 id=button3 name=button3>Remove Item</button>
<br>
<br>
</body>
</html>


it don't displaying name in the combobox ?
you may like to correct the my coding mistakes ?

regards.

Mateen


Quote:
quote:Originally posted by Imar
 With a little bit of imagination, this shouldn't be too hard to figure out.
Instead ot writing out the <select> once, you write out: dm.add(

And instead of each <option> element, you write out: new ComboBoxItem("Mateen",1),

and finally, instead of </select>, you write out: )

This way, you loop through your recordset and dump each record into a new ComboBoxItem.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Employee attendance form with DataGridView Dot_Net_Dev C# 3 June 8th, 2011 02:25 AM
Select the top 3 record of each employee phungleon Access 1 June 16th, 2007 01:16 AM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
When I hit save button the selected employee clear shoakat Classic ASP Databases 6 September 16th, 2004 01:41 AM
Spelling BruceFraser BOOK: Professional Crystal Reports for VS.NET 0 August 25th, 2003 12:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.