problem making <select> invisible

M

mitch

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.
 
M

Mitja Trampus

mitch said:
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>
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...
 
R

RobG

mitch said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top