/    Sign up×
Community /Pin to ProfileBookmark

Search Database

Using Ajax, Javascript, and a start and stop delimiter symbol “/”. How do I enable the user to type directly onto a page, without using a textbox. Upon each character being entered, how do I search a data for the complete string? (Minus the “/”)?

If the string corresponds to an id/string in the database , how do I display a message, notifying the user that a record was found?

The following code is what I have so far. This code enables the user to type directly onto a page. How do I add Ajax to the following code, in order to check the ID field in the database for the string entered onto the page?

[CODE]
<script type=’text/javascript’>
var x=null;
var y=null;
var tId = “”;
window.onload = function() {
x = document.getElementById(‘x’);
y = document.forms[0].copyField;
document.onkeypress = myOnKeyPress;
}
function myOnKeyPress(e) {
e = (e)?e:window.event;
key = (e.keyCode)? e.keyCode: e.which;
if (key==27) {
x.innerHTML =””; // escape pressed to clear the field
y.value =””; // remove if you do not want to clear field
}
else {
x.innerHTML += String.fromCharCode(key);
y.value = x.innerHTML;
}
}
</script>
[/CODE]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@adeang_1Feb 07.2008 — I think i know what your talking about, but ill try to help you out.

"http://w3schools.com/php/php_ajax_livesearch.asp"
Copy linkTweet thisAlerts:
@DysanauthorFeb 08.2008 — OK. Cheers! ?
Copy linkTweet thisAlerts:
@adeang_1Feb 09.2008 — Did that help you out? Cause i wasnt sure what you meant exactly.
Copy linkTweet thisAlerts:
@DysanauthorFeb 26.2008 — Sorry for late reply. BUSY!

Using my JavaScript code (that enables you to type directly onto page), how do I search a database for what was entered?
×

Success!

Help @Dysan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...