Kioskea
Recherche
Ask a question »

PHP - How to get Field value from a form?

March 2015


PHP - How to get Field value from a form?




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.
For unlimited offline reading, you can download this article for free in PDF format:
Php-how-to-get-field-value-from-a-form.pdf

See also

In the same category

Published by aakai1056.
This document entitled « PHP - How to get Field value from a form? » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.