Jump to content

Query without a button


Recommended Posts

Hi,im programing in asp vbscript.i have a textfield like this one:

<input type="text" name="code" id="code">

and i want something similar like the google page has:when the user starts writing in the search textfield, the system starts searching inmediately, without the need of the user pressing a button.this is my scenario:i have two texfields,the user will enter the code in textfield 1,and then will enter a name in texfield 2, in this moment when the user is in textfield 2 writing, the system could query to the database to check if the code already exists and tell the user to enter another code, without the use of a button.how can i do this?thanks..

Link to post
Share on other sites

Pick an event that you want to use to trigger the lookup, like keyup, change, blur, etc, and have an event handler for the event send the data to the server using ajax to do a lookup. The server would return whatever data you want to return, and the ajax handler can update the page with the data from the server. That's the general flow, you can learn more about events in Javascript and ajax communication in various tutorials.

Link to post
Share on other sites
Pick an event that you want to use to trigger the lookup, like keyup, change, blur, etc, and have an event handler for the event send the data to the server using ajax to do a lookup. The server would return whatever data you want to return, and the ajax handler can update the page with the data from the server. That's the general flow, you can learn more about events in Javascript and ajax communication in various tutorials.
i was thinking in the javascript event onmouseout:http://www.w3schools.com/jsref/event_onmouseout.aspso when the user goes out of the texfield, the query gets executed.i searched in google: asp vbscript select database onmouseout, but found nothingthere must be something in google, but i havent found it.could you tell me some search parameters to put in google?thanks Edited by derok
Link to post
Share on other sites

Search for each part, not the entire thing at once. ASP and VBscript have nothing to do with Javascript events, for example. W3schools has information about event handling in Javascript, if you search for "javascript event handling" you'll find plenty of information about that part. I would suggest the blur event instead of mouseout, blur fires when the field they were typing in loses focus, so when they click out of the field or press tab. The test code for your event handler can do something simple like show an alert box, so you can verify the event is firing when you expect it to.Once the event handler is set up, the next step is to search for information about ajax. You'll use Javascript to get the value in the field, and then have Javascript sent a request to the ASP page with the form data. Ajax is the process of sending that request and handling the response from the server. If you search for ajax you'll find plenty of examples there also.The ASP page is similar to a regular form processing page, where it gets the values from request.form or request.querystring and processes them. The main difference between a regular form processing script and an ajax processing script is that the ajax script needs to output something that Javascript can handle. There are several options for how you want to return the data back to Javascript and have it update the page. If you search for "ajax live search" you should find complete examples, even though they might use PHP instead of ASP.http://www.w3schools.com/ajax/ajax_aspphp.asp

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...