Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect a set of option being determined on what option you've chosen previously
    primarykey
    data
    text
    <p>I am using two selects, the one as the category and the second one as subcategory. I wish to make the second select menu to be determined by what option was chosen in the second select menu.</p> <p>Here is the html/php code.</p> <pre><code>&lt;select name="category" id="category"&gt; &lt;?php $options = array("Stationary", "Bag", "Paper"); foreach ($options as $option) { echo '&lt;option value"' . $option . '"'; if(in_array($option, $category)){ echo " Selected"; } echo "&gt;" . ucfirst($option) . "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;select name="subcategory" id="subcategory"&gt; &lt;?php $options = array("Pencils", "Ruler", "Pens"); foreach ($options as $option) { echo '&lt;option value"' . $option . '"'; if(in_array($option, $category)){ echo " selected"; } echo "&gt;" . ucfirst($option) . "&lt;/option&gt;"; } ?&gt; &lt;?php $options = array("Small", "Large", "Paper"); foreach ($options as $option) { echo '&lt;option value"' . $option . '"'; if(in_array($option, $category)){ echo " selected"; } echo "&gt;" . ucfirst($option) . "&lt;/option&gt;"; } ?&gt; &lt;?php $options = array("Notepad", "Plain ", "Colour"); foreach ($options as $option) { echo '&lt;option value"' . $option . '"'; if(in_array($option, $category)){ echo " selected"; } echo "&gt;" . ucfirst($option) . "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <p>I want it so when and you select one option from category it will it show the correct options to be shown in the <code>&lt;select&gt;</code>. </p> <p>I'm not sure if you can do this, but if anyone has an idea or know how to do this your help would be helpful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload