|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
drop down question
On my page I have 3 drop downs that are populated with static data. When my user makes a selection in either drop down I want to show my HTML table associated with that drop down selection, also the data in my tables are all static.
For example. if the user selects CAR - New in dropdown 1 I want to show a list of my new cars if the user selects TRUCK in dropdown 2, I want to hide my CARS and show my TRUCK list if the user selects BOATS - Fiberglass in dropdown 3, I want to hide (if shown) CARS, and TRUCKS and show my boat list. For now all of the data is static (don't ask) so I need to do all of this on the client. Is there a way to do this either using JavaScript, Div tags, CSS, etc. any help is apprecaited. "Scott" <Scott@community.nospam.com> wrote in message shown) >CARS, and TRUCKS and show my boat list.news:%23lvIbkgJIHA.5208@TK2MSFTNGP04.phx.gbl... >On my page I have 3 drop downs that are populated with static data. When my >user makes a selection in either drop down I want to show my HTML table >associated with that drop down selection, also the data in my tables are all static. > >For example. > >if the user selects CAR - New in dropdown 1 I want to show a list of my new cars >if the user selects TRUCK in dropdown 2, I want to hide my CARS and show my >TRUCK list >if the user selects BOATS - Fiberglass in dropdown 3, I want to hide (if > on the >client. Is there a way to do this either using JavaScript, Div tags,>For now all of the data is static (don't ask) so I need to do all of this CSS, etc. > Yes.Although I'm a bit confused by the UI design, if each choice in each dropdown is mutually exclusive with all the other choices why have multiple dropdowns? Give each table of data an ID attribute; give each table a Class="displayable" attribute. Give each option in the Select(s) a value which is the ID of the respective table. In a <style type="text/css"> element in the page head place this this style:- table.displayable {display:none} Now on the select element(s) add the attribute onchange="changeDisplay.call(this)" in Javascript var m_currentDisplayTable = null function changeDisplay() { if (m_currentDisplayTable) document.getElementById(m_currentDisplayTable).style.display = "none" m_currentDisplayTable = this.value document.getElementById(m_currentDisplayTable).style.display = "block" } BTW, for future reference for purely clientside questions the scripting.jscript group is a far more appropriate group. -- Anthony Jones - MVP ASP/ASP.NET thanks, its an odd design yeah I know, but its what the business wanted
Show quote "Anthony Jones" <A**@yadayadayada.com> wrote in message news:OECP0AhJIHA.4592@TK2MSFTNGP02.phx.gbl... > > "Scott" <Scott@community.nospam.com> wrote in message > news:%23lvIbkgJIHA.5208@TK2MSFTNGP04.phx.gbl... >>On my page I have 3 drop downs that are populated with static data. When >>my >>user makes a selection in either drop down I want to show my HTML table >>associated with that drop down selection, also the data in my tables are > all static. >> >>For example. >> >>if the user selects CAR - New in dropdown 1 I want to show a list of my >>new > cars >>if the user selects TRUCK in dropdown 2, I want to hide my CARS and show >>my >>TRUCK list >>if the user selects BOATS - Fiberglass in dropdown 3, I want to hide (if > shown) >CARS, and TRUCKS and show my boat list. >> >>For now all of the data is static (don't ask) so I need to do all of this > on the >client. Is there a way to do this either using JavaScript, Div > tags, > CSS, etc. >> > > Yes. > > Although I'm a bit confused by the UI design, if each choice in each > dropdown is mutually exclusive with all the other choices why have > multiple > dropdowns? > > Give each table of data an ID attribute; give each table a > Class="displayable" attribute. Give each option in the Select(s) a value > which is the ID of the respective table. > > In a <style type="text/css"> element in the page head place this this > style:- > > table.displayable {display:none} > > Now on the select element(s) add the attribute > onchange="changeDisplay.call(this)" > > in Javascript > > var m_currentDisplayTable = null > function changeDisplay() > { > if (m_currentDisplayTable) > document.getElementById(m_currentDisplayTable).style.display = > "none" > > m_currentDisplayTable = this.value > > document.getElementById(m_currentDisplayTable).style.display = "block" > } > > BTW, for future reference for purely clientside questions the > scripting.jscript group is a far more appropriate group. > > -- > Anthony Jones - MVP ASP/ASP.NET > > >
Other interesting topics
|
|||||||||||||||||||||||