Jump to content

creating 2 select menu's (2nd depending on 1st one)


senca99

Recommended Posts

hey every one,

 

I'm working on forms lately but there is one thing I don't understand.

I have a select menu in my html form. Now I want a second one underneath it whos values should vary depending on what the selection in the first menu is. For that I should use php but I don't know how. Can I somehow insert an if structure inside my html?

 

This is an example of my first select menu:

 

<select name="chooseCourse">
      <option value="One">One</option>
      <option value="Two">Two</option>
</select>

 

The next should be a menu containing different dates, displaying in the dropdown the correct dates for the above selected course:

 

<select name="chooseDate4CourseOne">
      <option value="first">10/10/2010-5/12/2010</option>
      <option value="second">5/12/2010-20/02/2011</option>
     <option value="third">25/02/2011-25/04/2011</option>
</select>

 

Now I was thinking how to create this. I thought the best way would be to make inside php an html part using :

 

<<<<_HTML_

in here a select date menu for the first course

>>>>

 

and make this for every date menu. Then simply use an if structure to do:

if firstvalue is selected, show firstdatemenu.

 

If the previous part would work it would leave me with one problem. The second menu will not be adjusted as long as the form is not submitted. Somehow when a selection is made, imediatelly the 2nd menu should be somehow adjusted/refreshed. How can I do this?

 

What do you think of the first part using those different html parts inside php? Would it work? And if so, how do make the date menu adapt?

 

a lot of thanks in advance!

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.