471,350 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 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 2132
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by c.anandkumar | last post: by
1 post views Thread by Jacky11 | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.