简体   繁体   中英

Prefill html form input fields using google sheet

I am trying to build a form which can be automatically filled means without any manual work. i am trying to create a form which will help in to find details of a student with just selecting its name from drop down box. Users just have to select the name, and its other details like age, hometown, father name will be automatically prefilled in the input fields. I have stored the details of every student on a google sheet. url of that google sheet is https://docs.google.com/spreadsheets/d/1NYFJrAZwJFoOo2fMXWW0EbOfYMZ9Ku0Ubdz50l2rxaI/edit?usp=drivesdk

now, i just have to link my html page and this google sheet to autofill input fields. given below is my html code.

 <html> <head> <title>details of student</title> </head> <body> <form> <select> <option>Amit</option> <option>Yash</option> <option>Abhay</option> <option>Ajay</option> <input type="button" id="autofill" value="autofill"> </input> </select><br /><br /> Age<input type="number"></input> <br /> Home town<input type="text"></input> <br /> Father<input type="text"></input> </form> </body> </html> 

when the user will click input button (id=autofill), the fields should get filled with the details of the selected name in drop down box. i tried on google to find any relevant sample or example. but didn't find any such thing. hopefully, coders at Stackoverflow would help me to complete this task. can anyone please help me in completing this task.

There are two ways of processing that data;

One is to download the file manually every time you run the code. This is bad.

Second is to use the Google Sheets API. I'm guessing you are using php. So you can take a look at Google Documentation for Sheets API:

https://developers.google.com/sheets/api/quickstart/php

Please read the documentation well. it will guide you.

Note that you can find Google API PHP client here

https://github.com/googleapis/google-api-php-client

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM