Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
How to make search txt file and display value to input?

My files on my directory are like this:

index.html
mobile.txt
adress.txt
country.txt

My HTML is like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form id="myform" method="post">
    <input type="text" id="nameTxt" placeholder="Please Enter Your txt name hire"/>
    <input type="submit" id="findTxt" value="search"/> 
</form>

I want to display the contents of the search results:

<input type="text" id="diplayTxt" value=""/>

I tried this but it still fails:

$(document).ready(function(){
  $("#myform").submit(function (event){
    event.preventDefault()
    var obj = document.getElementById("nameTxt").value;
    var dTxt = document.getElementById("diplayTxt");
    
    $.post("index.php", {obj:obj}, function(data){
      dTxt.value = data;
    });
  });
});

Here is the PHP code:

<?php
$ft = $_POST['obj'];
$fh = fopen($ft.".txt", "r");

while ($line = fgets($fh)) 
{
  echo $line;
}
fclose($fh);
?>

Please help me to fix it.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!