hi all,
i have a drop down list such as:
<select>
<option value="">select a room</option>
<option value="1">1 Room</option>
<option value="2">2 Room</option>
<option value="3">3 Room</option>
<option value="4">4 Room</option>
<option value="5">5 Room</option>
</select>
when i select lets say '1 room' i want to display one select box with the options
<select>
<option value="">select people</option>
<option value="1">1 adult</option>
<option value="2">1 adult + 1 child</option>
<option value="3">1 adult + 2 children</option>
</select>
when i select lets say '2 room' i want to display two select box's with the options
<select>
<option value="">select people</option>
<option value="1">1 adult</option>
<option value="2">1 adult + 1 child</option>
<option value="3">1 adult + 2 children</option>
</select>
<select>
<option value="">select people</option>
<option value="1">1 adult</option>
<option value="2">1 adult + 1 child</option>
<option value="3">1 adult + 2 children</option>
</select>
and 3 select boxes if i pick option '3 Room'
This can not be done in php, so i need to do it in javascript. how can i create select boxes on the page depending on the option picked.
select box on the fly
Moderator: General Moderators
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Re: select box on the fly
You can put all your select boxes that you might need into <div></div>'s and then make them visible/invisible based on what you need.
You don't want to use PHP for this because you don't want the user to have to go back and forth to the server? That's a reasonable decision.
You could also dumb-down the interface a bit, rather than making it quite so dynamic. (And more likely to break)
Maybe just have a Room 1 section and a Room 2 section. If they don't have a second room, they don't fill that section out. Within each room, have a drop down of number of people.
As a user and a developer, I like dumb computers and smart people. But not everyone feels that way.
You don't want to use PHP for this because you don't want the user to have to go back and forth to the server? That's a reasonable decision.
You could also dumb-down the interface a bit, rather than making it quite so dynamic. (And more likely to break)
Maybe just have a Room 1 section and a Room 2 section. If they don't have a second room, they don't fill that section out. Within each room, have a drop down of number of people.
As a user and a developer, I like dumb computers and smart people. But not everyone feels that way.
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Sorry, no. I know it can be done, that's what DHTML is all about. But I don't know how to do it. If you pop over to microsoft.com, and look for things that go visible/invisible as you click on stuff, then do a view source, you can see how they're doing it.gurjit wrote:can you show me some code of how to do this?
Or search in google on DHTML.
Sorry I can't be more help.