473,507 Members | 12,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide a DIV element based on dropdownlist selection

Good morning all,
Any ideas for an easy function to show/hide a DIV element? I have two drop
down lists on a page. I have two div elements I want to show and hide. If
you select "other" in dropdownlist 1 I want to show hidden DIV 1, or if the
user selects "other" in dropdownlist 2 I want to show hidden DIV 2. And
vice versa, if "other" is not selected, I want to show the relevant div. I
can do this with two different function, but i think I could combine this
into one function. I want to call this from either dropdown and pass itself
to the function, if the dropdownlist is dropdown1 I want to evaluate it and
hide/show DIV1, or if it's dropdown2, I want to show/hide DIV2. Any
suggestions? Thanks Everybody.

Regards,
Chris
Oct 26 '05 #1
1 6083
Chris Kettenbach wrote:
Good morning all,
Good evening.
Any ideas for an easy function to show/hide a DIV element?


Script:

function setStyleProperty(o, sProperty, value)
{
if (o)
{
if (typeof o.style != "undefined")
{
if (typeof o.style[sProperty] != "undefined")
{
return (o.style[sProperty] = value) == value;
}
}
// for NN4, positioned elements only
else if (typeof o[sProperty] != "undefined")
{
return (o[sProperty] = value) == value;
}
}

return false;
}

function show(o)
{
return setStyleProperty(o, "visibility", "");
}

function hide(o)
{
return setStyleProperty(o, "visibility", "hidden");
}

var ref = referenceToDivElement;
HTML:

<select ... onchange="(condition) ? show(ref) : hide(ref);">
BTW, I think that's a FAQ.
HTH

PointedEars
Oct 26 '05 #2

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

Similar topics

3
23851
by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data">...
27
4683
by: Nicholas Couch | last post by:
I have a little form with a couple of dynamically generated list boxes. When the user makes a selection from the first box, the second box is refreshed. When they make a selection from the second...
3
10174
by: veganeater | last post by:
Hi, I'm wondering if there's a way that I can select which <div> to show based on the user's selection from a dropdown/listbox form. <form name="form1" method="post" action=""> <select...
1
1169
by: serge calderara | last post by:
Dear all I have an ASP 1.1 application on which my user can filled some selection querry field like : ProductCatergorys (DropDownlist box) Product names (DropDownList) product number (text...
5
4557
by: srampally | last post by:
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much...
11
5787
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
0
1258
by: frankiefrank | last post by:
Hello, I have an aspx page with a RadioButtonList that has two Items, and a "ComboBox" (DropDownList) that I want to populate based on the selection in the RadioButtonList. The first...
6
3202
by: Doogie | last post by:
Hi I have an img control I am trying to hide upon certain types of commands in my code behind. When to hide it is directly tied to a asp:dropdownlist control. So depending on what the user...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.