Home > Archive > ASP > November 2007 > drop down question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
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.
| |
| Anthony Jones 2007-11-16, 6:56 pm |
|
"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 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
"Anthony Jones" <Ant@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...
> all static.
> cars
> shown) >CARS, and TRUCKS and show my boat list.
> on the >client. Is there a way to do this either using JavaScript, Div
> tags,
> CSS, etc.
>
> Yes.
>
> Although I'm a bit 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
>
>
>
|
|
|
|
|