How do I retrieve a value from local storage and set it in an HTML input field?

I am building a prescription maker. But I am facing a problem. I want to show to localstorage data in the select box. But I can’t. So I need help. Actually i just need a function that detects my row index of table and print the data according to the index in the input field. Thanks in advance

        function editpres(){   
    var aha = JSON.parse(localStorage.getItem('books'));
    
    
    document.getElementById('name').value = aha[0].name;
    document.getElementById('age').value =aha[0].age;
    document.getElementById('sex').value = aha[0].sex;
    document.getElementById('date').value = aha[0].date;
    document.getElementById('disease').value = aha[0].disease;
    document.getElementById('dignosis').value = aha[0].dignosis;
    
    }
    
    <html>
    <div>      
        <table class="table table-success table-striped ">
        <thead>
          <tr>
            <th>Patient Name</th>
            <th>Age</th>
            <th>Sex</th>
            <th>Date</th>
            <th>Disease</th>
            <th>Dignosis</th>
            <th>Medicine</th>
            <th>Test</th>
            <th></th>
          </tr>
        </thead>
        <tbody id="book-list"></tbody>
      </table>
    </div>
    </html>