Php and AJAX Live Search


There are 3 pieces of information, title and content, for each person in the database.
In live search, I want to make a live search only from the red-framed area.
My question is:
Ekran görüntüsü 2022-05-23 175919

The search result seen in the picture is the title 1 results.
When I click on one of these results I want it to add content to all fields.
How can I do that?

<script type="text/javascript">

        $("#baslik_1").on("keyup input", function(){
            var inputVal = $(this).val();
            var resultDropdown = $(this).siblings(".liveresult");
                $.get('livesearch.php', {term: inputVal}).done(function(data){
        $(document).on("click", ".liveresult li", function(){

<input type="text" class="form-control" id="baslik_3" name="baslik_3" placeholder="Başlık 3" autocomplete="off" required>
<textarea class="form-control" rows="5" name="adres_3" id="adresi_3" placeholder="Adres 3"></textarea>

<input type="text" class="form-control" id="baslik_2" name="baslik_2" placeholder="Başlık 2" autocomplete="off" required>
<textarea class="form-control" rows="5" name="adres_2" id="adresi_2" placeholder="Adres 2"></textarea>

<input type="text" class="form-control" id="baslik_1" name="baslik_1" placeholder="Başlık 1" autocomplete="off" required>
<ul class="list-group liveresult"></ul>
<textarea class="form-control" rows="5" name="adres_1" id="adresi_1" placeholder="Adres 1"></textarea>

Well, there are three ways to do this. Each one is useful for different reasons. It depends on where this data is coming from. Let’s talk about the data only for right now.

1 - Data comes from a database when the page loads and is stored in hidden DIV’s.
2 - Data comes from a database when the page loads and is stored in Javascript routine as VAR’s
3 - Data is not loaded until the drop-down is clicked and dynamically loaded using JS/AJAX calls to server

I assume you probably are talking about #3. Here is a link to StackOverflow that discusses all of these 3 options and how to handle them. ( They call them A,B,C ) Kind of a long post, but, covers everything you need to learn about these processes. One issue would be that you need to combine your look-ahead and the AJAX call together, but, should not be a problem. Good luck! Dynamic Load from Drop-down

Thank you for the answer,
The value selected from the search result list is querying again with another ajax
and I get the data with json

I write the information as below in the whole field

	url: 'ara.php',
	method: "POST",
	dataType: "json",
	data: { secilen : secilen },
	success: function (gelen) {
Sponsor our Newsletter | Privacy Policy | Terms of Service