Jump to content

Recommended Posts

ok, I know this is possible, but I dunno how to go about doing it....

 

I have a database of project number, client info, address, phone, ect...

 

And I have a form to add data, and one to edit data...

 

On the edit data form, I want to set it up so that when the project number is highlighted via a pull down list of active project numbers, that project number fill auto fill the form with the clients info from the database. Then, the user can edit this info...and submit the mofifications.

 

Is this done with php, javascript, or ajax?

Which is best?

I'm pretty sure this could be done with php, but how? Can I get an example of code? a good starting point...

 

any insight, info is helpfull!

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/69232-populate-form/
Share on other sites

Hmmm....I'm a newbie to ajax...looks cool, but complicated...

 

If I create a pulldown menu of project numbers... then based on the number that is picked, can't I get it to query the info already in the database and populate the form with the data?

But with this method I'd need to know #1 how to create a pulldown query, and #2 how to populate the fom fields with the data from the database based on the query.

 

Can someone help me with examples?

 

Like I said ajax looks cool...but I can't find anything newbie enough to explain it and get me going...

Link to comment
https://forums.phpfreaks.com/topic/69232-populate-form/#findComment-348507
Share on other sites

If you want someone to write this for you, post int he freelance forum. We are here to help, not do it for you.

 

You need an AJAX solution.

 

That does not mean you need to write queries into the select list. Here is one process for accomplishing this:

 

1. When page first loads query the database for the list of projects by ID and possibly a description. Take that list and populate the drop-down with the ID as the value and description or ID as the label. The first item in the list shuld have a null value and a label of "Select a project". Include an onchange event for the select list which calls a javascript function and passes the project numeber.

 

2. Create a JS function that takes a project ID and makes an AJAX call to a PHP page. That page will return back the data for the specific project and then the rest of the JS function will populate the form.

 

3. Create a PHP page which will accept a variable ($_GET) for a project ID and then returns back the field data for that project ID.

Link to comment
https://forums.phpfreaks.com/topic/69232-populate-form/#findComment-348642
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.