xanie Posted February 6, 2013 Share Posted February 6, 2013 <select name="lens"> <option value="Amber">Amber</option> <option value="Copper">Copper</option> <option value="Yellow">Yellow</option> <option value="Gray">Gray</option> <option value='Blue'>Blue Mirror</option> </select> <font size="2"> Frame: </font> <select name="frame"> <option value='Black'>Black</option> <option value='Sand'>Sand</option> <option value='Tortoise'>Tortoise</option> </select> i am trying to create two drop down menus: in blue mirror, the only available frame is black, how can i make in into a conditional statement wherein once you choose blue mirror the only option that will appear for frame is Black?? help me with this guys.. thanks. Link to comment https://forums.phpfreaks.com/topic/274095-option-value-in-a-conditional-statement/ Share on other sites More sharing options...
Love2c0de Posted February 6, 2013 Share Posted February 6, 2013 If you are going to be displaying certain things depending on what a user chooses, I would create your form with PHP, using if statements to decide what to display and what not to display. Regards, L2c. Link to comment https://forums.phpfreaks.com/topic/274095-option-value-in-a-conditional-statement/#findComment-1410417 Share on other sites More sharing options...
Andy123 Posted February 6, 2013 Share Posted February 6, 2013 If you want to change the available options in select #2 when you select something in select #1, then what you are looking for is Javascript and not PHP. If you want to filter from the same options in select #2 for every option in select #1 (that is, the options to be displayed in select #2 are always a subset of all possible options in select #2), then pure Javascript would do. If you just have few different options in select #2, then you could hard code this in HTML/Javascript. If you need more options and flexibility, then you could bring PHP into the picture by firing AJAX requests to your web server when a user chooses an option in select #1. You could always cache this in Javascript if you think there is a chance that people will be making many changes (although this is overkill in most situations). Link to comment https://forums.phpfreaks.com/topic/274095-option-value-in-a-conditional-statement/#findComment-1410436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.