473,662 Members | 2,406 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 6089
Chris Kettenbach wrote:
Good morning all,
Good evening.
Any ideas for an easy function to show/hide a DIV element?


Script:

function setStylePropert y(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 setStylePropert y(o, "visibility ", "");
}

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

var ref = referenceToDivE lement;
HTML:

<select ... onchange="(cond ition) ? 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
23875
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"> <input type="submit" name="mainform_action" value="Delete Data"> If the first radio button is selected, I only want all three buttons to be visible to the user. If the second radio button is selected, I only want the "Edit Data" and "View Data"...
27
4723
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 box, I concatenate the selections from the two boxes and add the string to a list at the top of the form, using createElement and appendChild. The list is actually a bunch of span elements contained within a div. Each span element includes a small...
3
10192
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 name="internet"> <optgroup label="Network"> <option label="option1">Internet</option> </optgroup>
1
1172
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 box) At the form load, a dataset object contains product category information
5
4567
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 simpler. Here is what I have until now. Problems with my code: 1. The selection list becomes invisible when I try to select an option (in Firefox). 2. The selection list stays visible when I just place the cursor over selection list and move...
11
5805
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
0
1266
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 RadioButtonList option is the default so I want to populate the dropdown list based on that in the beginning. Then every time the user clicks a radiobutton the dropdownlist items collection is cleared (in the SelectedIndexChanged event) and then the...
6
3210
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 selects in that dropdownlist, this image will be hidden or be displayed. I have tied the onselectedindexchanged value of the dropdownlist to a c-sharp method (not javascript) because other things are being done as well that I want to do server side. ...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8545
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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 we have to send another system
2
1747
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.