RonnieCosta50 Posted June 3, 2013 Share Posted June 3, 2013 I have a textbox. When the text that is typed into the textbox changes, I want to search my database for what is in the textbox. I want to do this rather than a search button because my website is really complicated and I'm simplifying it in my explanation to make it easy to understand. I currently have an alert in my textbox that displays the text that was typed in the textbox on change. It looks like this. <input name="txtPlayerName" tabindex="0" style="width: 150px; background-color: #BBAE85;" maxlength="15" required="required" autofocus="autofocus" placeholder="LoU screen name" onchange="alert(this.value)" /> I have a seperate php file called search.php. It contains my code to search the database based on criteria in my input textboxes. Question: How do I tell the textbox to run search.php onChange? Quote Link to comment Share on other sites More sharing options...
PravinS Posted June 3, 2013 Share Posted June 3, 2013 First option is that you can submit the form to search.php page on onchange event of textbox And second you can use AJAX Quote Link to comment Share on other sites More sharing options...
RonnieCosta50 Posted June 3, 2013 Author Share Posted June 3, 2013 I don't know any AJAX so that option is out the window. As for submitting the form to search.php... If I submit a form then it will reload the whole website. I only want it to search the database and display the data into the website without reloading the website. There are many textboxes and it would not work to reload the page every time a user switches textboxes. Quote Link to comment Share on other sites More sharing options...
Solution PravinS Posted June 3, 2013 Solution Share Posted June 3, 2013 so to avoid reloading a page you should use AJAX refer this url: http://www.w3schools.com/php/php_ajax_database.asp Quote Link to comment Share on other sites More sharing options...
RonnieCosta50 Posted June 3, 2013 Author Share Posted June 3, 2013 Thank you. That was exactly what I needed to get this working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.