senca99 Posted December 3, 2010 Share Posted December 3, 2010 hey every one, I'm working on forms lately but there is one thing I don't understand. I have a select menu in my html form. Now I want a second one underneath it whos values should vary depending on what the selection in the first menu is. For that I should use php but I don't know how. Can I somehow insert an if structure inside my html? This is an example of my first select menu: <select name="chooseCourse"> <option value="One">One</option> <option value="Two">Two</option> </select> The next should be a menu containing different dates, displaying in the dropdown the correct dates for the above selected course: <select name="chooseDate4CourseOne"> <option value="first">10/10/2010-5/12/2010</option> <option value="second">5/12/2010-20/02/2011</option> <option value="third">25/02/2011-25/04/2011</option> </select> Now I was thinking how to create this. I thought the best way would be to make inside php an html part using : <<<<_HTML_ in here a select date menu for the first course >>>> and make this for every date menu. Then simply use an if structure to do: if firstvalue is selected, show firstdatemenu. If the previous part would work it would leave me with one problem. The second menu will not be adjusted as long as the form is not submitted. Somehow when a selection is made, imediatelly the 2nd menu should be somehow adjusted/refreshed. How can I do this? What do you think of the first part using those different html parts inside php? Would it work? And if so, how do make the date menu adapt? a lot of thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/220541-creating-2-select-menus-2nd-depending-on-1st-one/ Share on other sites More sharing options...
The Letter E Posted December 6, 2010 Share Posted December 6, 2010 This is best done with AJAX using the new HttpRequestObject() function. You should post this question on the AJAX help and I'm sure you will get a great answer. Although, If you are unfamiliar with Javascript there might be a slight learning curve. Quote Link to comment https://forums.phpfreaks.com/topic/220541-creating-2-select-menus-2nd-depending-on-1st-one/#findComment-1143706 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.