Jump to content

Search the Community

Showing results for tags 'get value'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 1 result

  1. Hello guys, I've added a search bar in my website using php and javascript. It selects data from database according to your search input and then it displays the results. That works just fine but when the user select one of the resulted options I want to put the value of the specific option in the textbox or below so I can have access to it. So if for example someone will search the word "Car", when they click the word I just want to get the value like we normally do in PHP ( $car = $_POST['car']; ). Is there any way I can do it? main.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#SearchInput").focus(function() { if($("#SearchInput").val() == "Car Search") { $("#SearchInput").val(""); } }); $("#SearchInput").blur(function() { if($("#SearchInput").val() == "") { $("#SearchInput").val("Car Search"); } $("#SearchResults").slideUp(); }); $("#SearchInput").keydown(function(e) { if(e.which == { SearchText = $("#SearchInput").val().substring(0, $("#SearchInput").val().length-1); } else { SearchText = $("#SearchInput").val() + String.fromCharCode(e.which); } $("#SearchResults").load("retrieveCar.php", { SearchInput: SearchText }); $("#SearchResults").slideDown(); }); }); </script> </head> <body> <table> <tr> <td><div id="SearchBox"><input id="SearchInput" name="SearchInput" value="Car Search"/></div></td> <td><div id="SearchButton"><input type="image" src="images/left.png" /></div></td></tr> <tr><div id="SearchResults"></div> </tr> </table> retrieveCar.php <?php $dbc = @mysql_connect ('localhost','root@localhost',''); // Select the database. mysql_select_db ('model'); if(isset($_POST['SearchInput'])) { $SearchInput = strtolower($_POST['SearchInput']); $Cars = mysql_query('select * from Cars where car_name like "%'.$SearchInput.'%"'); while($Car = mysql_fetch_assoc($Cars)) { $Name = utf8_encode($Car['car_name']); $Name = str_replace($SearchInput, '<span class="highlight">'.$SearchInput.'</span>', $Name); $Name = str_replace(ucfirst($SearchInput), '<span class="highlight">'.ucfirst($SearchInput).'</span>', $Name); echo '<a href="">'.$Name.'</a>'; } } ?>
  • 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.