PHP - How to get Field value from a form?

January 2017




Issue


In a form I have a dropdown field result of an application. I have a combo second field whose content will depend on the choices made in the first box.
As not get the value of the initial field (without sending the form to submit server).

Solution


Two solutions:
  • 1 - you accept that your page will reload, then you do not use javascript, but in the list you put an:

onChange = Submit (). In <form you put action="your_page_php.php"

In your_page_php you check that $ _POST ['name_list1']!="" set your database and load your second list.

For the selected value of your first list, you have to put in all:
  • 2 - If you do not wish your page to reload when you use Javascript and AJAX is to call another PHP script that will read the database and load the list into two FCT lists.

Do a Google search on "Ajax-related lists ".

Note


Thanks to Alain42 for this tip.

Related


Published by aakai1056. Latest update on April 27, 2010 at 05:44 AM by aakai1056.
This document, titled "PHP - How to get Field value from a form?," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).