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;
        <table class="table table-success table-striped ">
            <th>Patient Name</th>
        <tbody id="book-list"></tbody>