473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Javascript to access mysql db?

Hi all, I was wondering if there was any way that I can have a webpage with
a text field that acts as a search box and when someone types even one
character (letter or number) into the text field, it will access a mysql
database and show results for any field in the db that starts with that
letter. This is essentially an instantaneous database search script. Any
ideas?

Some things to consider: when someone types in multiple characters, the
database needs to be accessed everytime for each character. For example,
someone types into the text field very quickly the letters: "ted" The
javascript will search the database for any entries that start with "t",
then narrow it down to all entries that start with "te" then all entries
that start with "ted"...etc.

And it if cannot be done in javascript, can it be done in any other
language?

Thanks in advance,

Mosher

Jul 23 '05 #1
3 5167
Using Microsoft technology, you'd code:

var oCn=new ActiveX("ADODB.Connection")
oCn=sYourConnectionString
oCn.open
var oRs=new ActiveX("ADODB.Recordset")
..... etc

The user will probably get "this is unsafe, press yes to continue"
message boxes here, but it will work.

Jul 23 '05 #2
Sorry, a slight inaccuracy in my previous post (the memory is gone)

oCn=new ActiveXObject("ADODB.CONNECTION")

Previously, I had posted simply "new ActiveX" instead, sorry

Jul 23 '05 #3
In article <y6********************@comcast.com>, mo***********@yahoo.com
enlightened us with...
Hi all, I was wondering if there was any way that I can have a webpage with
a text field that acts as a search box and when someone types even one
character (letter or number) into the text field, it will access a mysql
database and show results for any field in the db that starts with that
letter. This is essentially an instantaneous database search script. Any
ideas?

Client-side Javascript cannot by itself talk to a server-side database. It
needs help.
Some things to consider: when someone types in multiple characters, the
database needs to be accessed everytime for each character.
That's not a good idea in general.
Do you know how long that will take? For each DB query, a request has to go
to the server. Then the server has to run something that queries the DB. Then
the response has to go back to the client.
You'll need to optimize the hell out of the script, the DB, and your
connections big time.
Google manages it, so it CAN be done. In theory. :)

And it if cannot be done in javascript, can it be done in any other
language?


There was a thread around here about Google's adwords program (I think) that
was talking about how they used client-side javascript xmlhttp request to
talk to their server-side process that does something VERY similar to this.
Check the archives for the thread.

--
--
~kaeli~
If a parsley farmer is sued, can they garnish his wages?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: SuperPippin | last post by:
Hello all ! I am a bluebit in JavaScript. I would like to write a little program to read data in a MySQL database. What do I need ? Is there a specific "JavaScript Include" to make this work ?...
2
by: mir nazim | last post by:
hello, i am writing an application and need to access mysql od sqllite from javascript. is it possible to access mysql/sqllite (or any free lightweight relational databse) directly from...
2
by: RootShell | last post by:
Hello First of all i know that PHP is a server side, and JavaScript is a Client side programming language, but i need to know if there is any way i can add the variable "countDownInterval" from...
1
by: mike | last post by:
I'm fairly green with javascript, and have been looking everywhere for an example of how to load data from a mysql db into javascript arrays. For a little background on what I'm trying to do, any...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: Vanessa | last post by:
Hi there I am an Access developer, and I have written applications for a 30 telephone call center, using the standard multiuser jet engine, it all works fine, but I want to move our systems onto...
4
by: linusthefish | last post by:
Is it possible to use JavaScript & MySQL? What I'm looking to do is query a database and then output the results in a popup window. I've got the popup window part down, I just can't figure out...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.