Jump to content

Search Database


Dysan

Recommended Posts

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?

 

<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>

Link to comment
Share on other sites

This is the php section. While Ajax can access php documents, it isn't a php technology, so you are asking in the wrong place.

 

That being said, even if you go to the right place (there is an ajax section of the forum), I doubt you are going to get an answer. Its one thing to ask someone to help you fix a script you can't get working, its another thing to ask for a lesson from scratch.

 

If you are willing to pay the money to get it done, feel free to send me a private message. I'll write you script for you for a fee.

 

How do I enable the user to type directly onto a page, without using a textbox

 

A what? I don't think there is a such thing as a textbox. there are text inputs and text areas though. But assuming thats what you meant, you can't do what you are speaking of. Text can only be typed into a text input, a text area, or maybe a file input, although thats a little different.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.