Forum Moderators: coopster

Message Too Old, No Replies

Need help with PHP form sub-selections

         

btvbill

2:26 am on Aug 18, 2011 (gmt 0)

10+ Year Member



I need to build a form and send the results to a MySQL database which I know how to do.
The part I need help with is that the form has a couple fields that will then open a new form field based on what is chosen.
For instance:
First selections (either radio or checkboxes)
- New Book
- Revise existing Book

If New Book is selected, a textarea box allowing for the Book Description would appear.

If Revise existing Book is selected, a text box asking "date of original publication" would appear and a second textarea box would appear for "Indicate changes".

Any help would be appreciated!

penders

6:31 am on Aug 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One way... more of a CSS/JavaScript question than PHP. The 'hidden' form elements would be present when the page first loads. JS hides the non-default elements initially (so to be accessible to non-JS users). JS controls the show/hide of these elements based on user action, perhaps by applying CSS classes. All elements are submitted back to the server. PHP validates based on user selection.

If the selection is either "New Book" OR "Revise existing Book" (not both) then you should use radio buttons, otherwise you'll never be able to validate the correct response.