Hello. I have a search engine form that is not ajax and it refreshes the page on search. I was wondering if it is possible to type a onclick code where it will contain my php script for the search engine by when you search, it'll send show the result in a div tag?

If this is possible, can someone help me get started. I'm a very beginner at ajax.

Thank you

Right... Well you need to isolate the search code out of the php and put in in search_engine.php . search_engine.php retrieves the variables out of the URL using GET and searches your database. Then it echoes all the rows found.

Then you create a JavaScript function that retrieves the value out of the textbox that contains the search-words, and add that to the url (e.g. search_engine.php?q=my+search+words . Then use AJAX to call the page (using the URL you formatted) and then when the states are correct, use a document.getElementById('yourdivid').innerHTML = ajax.responseText; to show the results.

~G

I already created my search engine script in another php. I'm not sure how to create the javascript function to retrieve the value.

Can you help me out with the script?

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.