I'm having some trouble getting something to work. I'm not even sure
whether or not this is possible, but it *seems* like it should be.
I've done a fair amount of experimenting and googling...but maybe I'm
still missing something obvious...
I'm trying to have a <div> appear and disappear based on what a
switchbox is set to. Having <div style="display: none;"> and then
setting the display property to inline onChange works fine, but I
can't make it disappear again when I onChange back to another value.
I have tried this various ways (including having an invisible class
and changing the class rather than the display property directly) and
I can't figure out a way to have it appear when the switchbox is set
to one value, and disappear if the switchbox is set to another value.
I also can't use OnLoad to set the display property of the div to
none, it has to be set in the div tag itself...which is another reason
why I suspect I'm doing something wrong.
The visibility property is no good because I don't want the div to
take up space.
Here is an example page that doesn't work in any version of IE I have
tried it in (reformatted for USENET..sorry about the readability).
It's set up this way because I need to use the same function for
different switchboxes and <div>'s. This is for a massive form/table
so a separate function for each instance is no good. Any possible way
of getting the div to disappear and not take up space again after it
is made visible is welcome.
TIA
<html>
<head>
<script type="text/vbscript">
<!--
Sub DivChange (yesnobox, layername)
Dim strObjName
strObjName = "document.MainF orm." & yesnobox & ".value"
If eval(strObjName ) = "No" Then
document.getEle mentById(layern ame).style.disp lay = inline
Elseif eval(strObjName ) = "Yes" then
document.getEle mentById(layern ame).style.visi bility = hidden
End If
End Sub
-->
</script>
</head>
<body>
<form name="mainform" >
<select id="test" name="CD-ROM required" class="normal"
onChange="DivCh ange 'test', 'test1'">
<option selected>
<option value="Yes">Yes
<option value="No">No</select>
<div id="test1" style="display: none;">testtest esttest</div>
</form>
</html>
-- endus -- at -- endus -- dot -- com --
Not knowing what you want out of life is a pattern in itself,
perhaps the most rigid pattern of all. As a matter of fact
it's probably the most predominant pattern in the country
today, and just another name, in the long run, for what we
call the "American way of life". You are in a large and
very crowded boat, floating around aimlessly and complacently
in a very treacherous sea. At times I seriously regret that
I've divorced myself so completely from that pattern. Life
is much simpler that way, and very often much more pleasant.
-Hunter S. Thompson
Comment