473,385 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

showing and hiding something based on selection made

I had this going yesterday, but it seems to be forgotten because it's
so far down the list now.

www.middletree.net/dropdown.htm This is from an Intranet app I have
going in ASP. I have no actual URL to show you, but this should work.

Find the <select> dropdown called Type of Ticket. Now find the one
called Environment. The boss wants a couple of things to be hidden from
the user unless both of the following two conditions are met:

1. "Problem" is selected on Type of Ticket.
2. "Production" is selected on Environment.

The part of the page that you'll want to key in on is the function
called displayRadios.

In the case of the page I am posting, please note that it's a page for
editing an existing ticket, so it happens to have Production and
Problem pre-selected. On other versions of this same page, other things
might be pre-selected.

Anyway, when this page, loads, it doesn't show the parts that I am
hoping will show. No JS error is present on load. However, when you try
and change either of the dropdowns, the JS function is fired off, and
that throws the error.

Any help appreciated.

Jul 23 '05 #1
4 2233
Not sure I fully understand, but this should be close:

I'm not sure what you want to show or hide from the user. I'll assume it's
in a <div id="secretstuff"> or <span id="secretstuff">

something like this maybe?

<html>
<head>
<title>Show/Hide Demo</title>
<script type="text/javascript">
function showhide() {
var typeofticket =
document.getElementById("typeofticket").selectedIn dex;
var environment =
document.getElementById("environment").selectedInd ex;
if (typeofticket == 1 && environment == 1) {
document.getElementById("secretstuff").style.displ ay = "inline";
} else {
document.getElementById("secretstuff").style.displ ay = "none";
}
}
</script>
</head>
<body>
<form>
<p><select size="1" name="typeofticket" onchange="showhide();">
<option>Choice 1</option>
<option>Problem</option>
</select><select size="1" name="environment" onchange="showhide();">
<option>Choice 1</option>
<option>Production</option>
</select></p>
</form>
<div id="secretstuff" style="display:none">Secret Stuff is here!</div>
</body>
</html>

"middletree" <mi********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I had this going yesterday, but it seems to be forgotten because it's
so far down the list now.

www.middletree.net/dropdown.htm This is from an Intranet app I have
going in ASP. I have no actual URL to show you, but this should work.

Find the <select> dropdown called Type of Ticket. Now find the one
called Environment. The boss wants a couple of things to be hidden from
the user unless both of the following two conditions are met:

1. "Problem" is selected on Type of Ticket.
2. "Production" is selected on Environment.

The part of the page that you'll want to key in on is the function
called displayRadios.

In the case of the page I am posting, please note that it's a page for
editing an existing ticket, so it happens to have Production and
Problem pre-selected. On other versions of this same page, other things
might be pre-selected.

Anyway, when this page, loads, it doesn't show the parts that I am
hoping will show. No JS error is present on load. However, when you try
and change either of the dropdowns, the JS function is fired off, and
that throws the error.

Any help appreciated.

Jul 23 '05 #2
FunGuySF wrote:
[...]
document.getElementById("secretstuff").style.displ ay = "inline";


Better to use:

...display = "";

then the default will be used (inline, block, whatever) and you don't
accidentally set it to the wrong one.

Please don't top-post and remove any unnecessary quoted text from the
reply (see the group FAQ at:

<URL:http://www.jibbering.com/faq/>

--
Rob
Jul 23 '05 #3
> RobG wrote:
[...]
Please don't top-post and remove any unnecessary quoted text from the
reply


My apologies :)

Mike
Jul 23 '05 #4
Thanks for your help. I have it now.
And for the record, I am pro-top-posting.

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
1
by: Jacky11 | last post by:
Can anyone help me? Please see the code I'm using now. Public Function sheetlayout() On Error GoTo Err_Command1_Click Dim xl As Object Set xl = GetObject("c:\windows\desktop\123.csv")...
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
1
by: Grimm | last post by:
I am developing an internalk inteface that integrates alot of seperate tools into one interface. The current version uses one Iframe inside a div layer for positioning. Currently the seperate web...
5
by: jonosborne | last post by:
Hi, i have managed to filter a report based on selections made in a list box but am totally confused with a message box that appears everytime i run my report. Let me explain (i apologise for...
17
by: rohitchawla | last post by:
i am trying to show and hide a div when onmouseover and onmouseover another div element. i am setting a setTimeout duration on onmouseout to delay the hiding of div for around two second The...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
9
by: Brett_A | last post by:
I have a form where the first field is a dynamic drop-down that pulls from a db (Access). The fields associated with the query are task_id, task_name and task_rate. The field has the value of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.