473,406 Members | 2,281 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,406 software developers and data experts.

Dropdown and list box selection show/hides DIV

I have a combo box whose values change depending on the value selected
in the dropdown menu beforehand. Essentially the drop down has
categories and the combo box are the actual topics.

That all works fine but know i need to find a way to show some text,
probably in a DIV, that is different for each of the values in the
combo box.
I have found a script that almost does this but it cannot work with the
combo box being changable.

Any one know how to do this?

Aug 2 '06 #1
3 2826

chris_huh wrote:
I have a combo box whose values change depending on the value selected
in the dropdown menu beforehand. Essentially the drop down has
categories and the combo box are the actual topics.

That all works fine but know i need to find a way to show some text,
probably in a DIV, that is different for each of the values in the
combo box.
I have found a script that almost does this but it cannot work with the
combo box being changable.

Any one know how to do this?
Example, and caveat, below:

<select onchange="changeText(this);">
<option>one
<option>two
<option>three
</select>
<div id="xx"></div>
<script type="text/javascript">
function changeText(el){
var txt = el.options[el.selectedIndex].text;
var div = document.getElementById('xx');
while (div.firstChild) div.removeChild(div.firstChild);
div.appendChild(document.createTextNode(txt));
}
</script>
Warning:
- Feature detection omitted.
- No error checking performed
- Using onchange with select elements may create usability issues.
--
Rob

Aug 3 '06 #2
chris_huh wrote:
I have a combo box whose values change depending on the value selected
in the dropdown menu beforehand. Essentially the drop down has
categories and the combo box are the actual topics.

That all works fine but know i need to find a way to show some text,
probably in a DIV, that is different for each of the values in the
combo box.
I have found a script that almost does this but it cannot work with the
combo box being changable.

Any one know how to do this?
// Make a text node:
NewText = document.createTextNode(This_Is_My_Text_Variable+" or literal
text");
// Put it into div by id
document.getElementById(DivObjectID).appendChild(N ewText);

hth

If you used my system it would be half the code:
// Put text in div
PutIn($text("some text goes in here"), $(DivObjectID));

http://darwinist.googlepages.com/htmldesktop.html

Aug 3 '06 #3
chris_huh wrote:
I have a combo box whose values change depending on the value selected
in the dropdown menu beforehand. Essentially the drop down has
categories and the combo box are the actual topics.

That all works fine but know i need to find a way to show some text,
probably in a DIV, that is different for each of the values in the
combo box.
I have found a script that almost does this but it cannot work with the
combo box being changable.

Any one know how to do this?
Oh, if you want to get the list index as well:

// list is a reference to the select box:
var optionvalue = list[list.selectedIndex].value;

hth

Aug 3 '06 #4

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

Similar topics

3
by: Jim Mitchell | last post by:
My Goal is to have a dropdown (DL2) filled from the selectIndexChange event of a primary dropdown (DL1). These are picklists that will be selected frequently. Can someone recommend a strategy...
9
by: Prowler | last post by:
In our current application we have a page whose sole purpose for existence is to permit the user to select from a list (subsequent to our login page). We would like to have the list drop down...
3
by: Jim Mitchell | last post by:
My Goal is to have a dropdown (DL2) filled from the selectIndexChange event of a primary dropdown (DL1). These are picklists that will be selected frequently. Can someone recommend a strategy...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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
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,...
0
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...

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.