sarasoorah Posted March 6, 2007 Share Posted March 6, 2007 Hello everyone, I'm trying to display a drop down list and let the user choose from it, then based on his choice another form will be displayed under the drop down list. I have more than 20 different forms, each one is saved on a php file, I need to save the selection from the drop down and the input from the form in the database. please, is there any way I can do this? or is there any other suggestion. I really need the help. Link to comment https://forums.phpfreaks.com/topic/41419-load-form-based-on-a-selection-from-a-dropdown-list/ Share on other sites More sharing options...
surion Posted March 6, 2007 Share Posted March 6, 2007 the only way i know to do this is using AJAX. after selecting in the first dropdown you call a javascript that sends your selected vars (both post or get) to the file that will be loaded in the div (the file that contains the next dropdown) on this site there is an example where you can see how vars can be send to a file loaded in a div http://www.captain.at/howto-ajax-form-post-request.php Link to comment https://forums.phpfreaks.com/topic/41419-load-form-based-on-a-selection-from-a-dropdown-list/#findComment-200643 Share on other sites More sharing options...
sarasoorah Posted March 8, 2007 Author Share Posted March 8, 2007 Hello, Thanks for the help, but I found another way to do it but I don't know if it is good after the drop down list ,I did the following for each form: print "<div id=\"f1\" style=\"display:none\">"; include("first_form.php"); print "</div>"; using "onchange" for the list that calls a javascript to change 'display' for the selection to 'block' Link to comment https://forums.phpfreaks.com/topic/41419-load-form-based-on-a-selection-from-a-dropdown-list/#findComment-202412 Share on other sites More sharing options...
skali Posted March 8, 2007 Share Posted March 8, 2007 What this will do is that your complete page will be generated at once with some forms hidden that you are trying to show with javascript. That's ok if you do not want to send some variables to the server after javascript selection and then generate new page on the basis of these variables. But if you want php to take some variables from javascript onchange command then i think you will have either use AJAX or refresh the page and send the variables as the query string for php to process and generate new page. Link to comment https://forums.phpfreaks.com/topic/41419-load-form-based-on-a-selection-from-a-dropdown-list/#findComment-202440 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.