Jump to content

Dynamic option box


blaze41

Recommended Posts

Hi all,

 

First off i thought this would be easier, but I cant seem to make it work. Im not that familiar with java and new to PHP trying things out so any help would be greatly appreciated. What I am trying to do is have to drop down boxes. The second ones information is dependent on the first one. The first one is static but depending on what is selected I want the second one to check my database and pull the list of items out of a table. The table categories are the values for the first drop down and "item" is the name of the info with in the table that I want the user to be able to select from the second drop down.

 

<form name='bm_table' action='add_bms.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Item:</td><td>
    
    <select name="cat">
        <option value="DSW">Full Size</option>
        <option value="MSW">Mid Size</option>
        <option value="PSW">Plug-In</option>
        <option value="CC">Scent Circle</option>
        <option value="FF">Fragrance Foam</option>
        <option value="RS">Room Spray</option>
        <option value="SB">Bar</option>
        <option value="SK">Brick</option>
        <option value="SP">Scent Pak</option>
        <option value="SY">Buddy</option>
        <option value="TP">Theme Pack</option>
        <option value="TT">Travel Tin</option>
        <option value="MISC">Misc</option>
    </select>
</td></tr>
<tr><td>
      <option name='item'>
          <option values dependent on what was selected>
     </option>
</td></tr>
<tr><td colspan=2 align='center'><input type='submit' value='Add To Inventory'></td></tr>
</table>
</form>

Link to comment
https://forums.phpfreaks.com/topic/236461-dynamic-option-box/
Share on other sites

With jQuery make an AJAX request for the change() event of the first dropdown: categories.php?cat=5

 

And that should echo a list with <option value="1">Frangrance #1</option> then you let jQuery insert the list into the second dropdown replacing its current contents.

Link to comment
https://forums.phpfreaks.com/topic/236461-dynamic-option-box/#findComment-1215723
Share on other sites

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.