473,386 Members | 1,699 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,386 software developers and data experts.

problem making <select> invisible

I have a <select> that's inside a <td> and I want to dynamically
show and hide the select. If elem is set to the <select> and I do
either of these:

elem.style.visibility = "hidden";
elem.style.display = "none";

it works in Firefox, but not in IE. In IE the page doesn't change at
all.

However if I set elem to the outer <td> and then do those two
statements, they both work just fine.

Does anybody know how to temporarily hide just a <select>?

Thanks.

Jun 24 '06 #1
2 6181
mitch wrote:
I have a <select> that's inside a <td> and I want to dynamically
show and hide the select. If elem is set to the <select> and I do
either of these:

elem.style.visibility = "hidden";
elem.style.display = "none";

it works in Firefox, but not in IE. In IE the page doesn't change at
all.
Make sure the problem is not elsewhere. The following two lines both work for me:
<select
onchange='this.style.visibility="hidden"'><option> foo</option><option>bar</option></select>
<select onchange='this.style.display="none"'><option>foo</option><option>bar</option></select>
However if I set elem to the outer <td> and then do those two
statements, they both work just fine.

Does anybody know how to temporarily hide just a <select>?

You /could/ enclose each select in a div...
Jun 25 '06 #2

mitch wrote:
I have a <select> that's inside a <td> and I want to dynamically
show and hide the select. If elem is set to the <select> and I do
either of these:

elem.style.visibility = "hidden";
elem.style.display = "none";

it works in Firefox, but not in IE. In IE the page doesn't change at
all.

However if I set elem to the outer <td> and then do those two
statements, they both work just fine.

Does anybody know how to temporarily hide just a <select>?


I agree with Mitja, it should work:

<script type="text/javascript">
function hideShow(id)
{
var es;
if ( document.getElementById
&& (es = document.getElementById(id))
&& (es = es.style)){
es.display = ('none' == es.display)? '' : 'none';
}
}
</script>

<input type="button" value="Hide/show select"
onclick="hideShow('sel_A');">
<select id="sel_A">
<option>foo
<option>bar
</select>
--
Rob

Jun 26 '06 #3

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

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
1
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php...
7
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option...
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
5
by: Brian Foley | last post by:
Hello, I am used to using the label tag with check boxes and radio buttons in html forms. This allows me to click on the text of the label to activate/deactivate the check box / button, rather...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
6
by: joseph.lindley | last post by:
Forgive me for I am a bit of a web-dev novice - but I'm not doing too bad. I'm currently working with a bit of javascript to dynamically add <option>s into a select box. My code currently works...
4
by: Man-wai Chang | last post by:
-- iTech Consulting Co., Ltd. Expert of ePOS solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883 Fax: (852)2325 8288
14
mikek12004
by: mikek12004 | last post by:
In a form I have 5 elements (e.g. pictures) and I wish for the user to be able to set the order of appearance. For this I have for each picture a select box (names select1 to select5) with "please...
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
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
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
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
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
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,...

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.