drop down question

S

Scott

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.
 
A

Anthony Jones

Scott said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top