Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.