ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am creating a web page where I need to get values from the database and fill the textboxes before submitting the form.
When I enter the employee ID, I should get the name of the employee when I click on a button "Get details".
What would help me to do this?
Well, you could have PHP on the page that checks the POST data for an "employeeID" value: if it's not present (when you first load up the page) or invalid, then it just displays a blank page, but if it matches a record in your employee database (when someone's filled in the field and clicked 'Get details'), then it loads up their details and puts them into the fields as defaults. Just make sure your code doesn't fall foul of SQL injection if you use this approach.
If you need more specific help than this, please show us the code you've written so far.
And on the server side, you'd have an endpoint at http://localhost/employees/<id> (say, http://localhost/employees/2), which returns JSON in the following format:
Employee ID: <input type="text" name="id" id="id">
<button id="getname">Get name</button>
Employee Name: <input type="text" name="name" id="name">
<span>Name does not exist for this id</span>
<br>
Now, the problem is that when I add the <form> tag to the html code, this code fails. The form gets submitted and
takes me to another page(action of form tag). I am working on it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.