Jump to content

option value in a conditional statement


xanie

Recommended Posts

<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

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.