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
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
Share on other sites

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.