Jump to content

I want a dropdown list clicked to another dropdownlist


Cyberoxy

Recommended Posts

Hi guys / galsI need to know who you can do writing in HTML:Dropdown list must be clicked to another dropdown list. When you select Accommodation, the other dropdown list should automatically display Garden Court and Clarens whichever you can select one. <select name="subject" id="txtSelect"> <option selected="selected" placeholder="" required>Please Select</option> <option>Accommodation</option> <option>Transport</option> </select> <select name="subject" id="txtSelect"> <option selected="selected" placeholder="" required>Please Select</option> <option>Garden Court</option> and <option>Clarens</option> <option>Greyhound</option> and <option>Intercape</option> </select> Your help will be highly appreciated.Thank youNatalie

Link to comment
Share on other sites

HTML alone cannot do this. You need some JavaScript.In your example, the select element is the same in all cases (same ID). Only the content changes. I hope this is not what you really mean, because users will find it very confusing.The more natural process would be for the Accommodations option to trigger changes in one select element and for the Transport option to trigger changes in a different select element. Or, if there is exactly one Accommodation to be selected, and one Transport to be selected, their names would not appear in a select element at all, but would appear as text somewhere else.Maybe you need to describe your project more completely. If your elements really do contain more information, please show it so we can make informed recommendations.

Link to comment
Share on other sites

You are right! I just changed my mind.I think it would be better if you click "Volvo" option, the image should display what Volvo looks like. How can I do this? <select name="subject" id="txtSelect"> <option selected="selected" placeholder="" required>Please Select</option> <optgroup label="SA Cars" onmouseover="expand(this);" onmouseout="collapse(this);">> <option value="volvo">Volvo</option> <option value="saab">BMW</option> </optgroup> <optgroup label="German Cars"> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> </optgroup> </select>

Link to comment
Share on other sites

1. layout your page so that in the initial condition, there is a placeholder image wherever you would like the cars to be displayed. This way, the shape of the document does not drastically change when a Volvo suddenly appears. The user will be accustomed to something existing in the display space. Assuming you go this route, the placeholder image will need an id attribute. This id will be used for the life of the document as a reference to the place where the images go.2. you'll need a place where each image URL is associated with the correct select option. It is common for the image URL to be placed in the value attribute of an option, like so:<option value="path/to/volvo.jpg">Volvo</option>This is the simplest technique. Alternatively, that data can be stored as a JavaScript object. You might need that if the value attribute must contain other information for some other purpose.3. In any case, you'll need some JavaScript that makes the swap. I hesitate to suggest any until you make some decisions about the things I've mentioned.

Link to comment
Share on other sites

  • 2 weeks later...

here's an example of selected drop down list.You can also select a particular bike in preference to others.Choose your favourite bike.<select name="bikes"><option value="Honda CBR">Honda CBR</option><option value="Ninja">Ninja</option><option value="HayaBusa">Hayabusa</option><option value="Harley Davidson" selected="Harley Davidson">Harley Davidson</option></select>for dropdown list in another dropdown list you need to learn java script.

Link to comment
Share on other sites

actually both the things work be itoption value="Harley Davidson" selected="selected">Harley Davidson</option>option value="Harley Davidson" selected="Harley davidson">Harley Davidson</option>check the result @HTML Dropdown List.tnx for ur suggestions.

Link to comment
Share on other sites

actually both the things work be itoption value="Harley Davidson" selected="selected">Harley Davidson</option>option value="Harley Davidson" selected="Harley davidson">Harley Davidson</option>check the result @HTML Dropdown List.tnx for ur suggestions.
Yes, it works, but it's not standard and browsers may not necessarily do it. Browsers are very forgiving. This code would also work:<option value="Harley Davidson" selected="A random string with no meaning">Harley Davidson</option>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...