lawrence wrote:
[...]
Better to post functional (though minimal) code, otherwise the bits we
fill in may be where the real issue is:
<form action="">
>
> <input type="Submit" value="Click here when done"> <br /> <br />
I presume you are using HTML 4, so use <br>
> <script language="javascript">
Ditch language attribute, replace with type:
<script type="text/javascript">
> document.getElementById('optionalDiv').style.visib ility='hidden';
> document.getElementById('optionalDiv').style.displ ay='none';
>
If hiding using display, there is no real need to also hide using
visibility. Also, you have placed this code above the HTML element it
refers to, so the browser will start executing the script possibly
before the element is created in the DOM. I've put this into the
header, however if there is a lot of stuff to load after, then the user
may see the DIV shown, then hidden. In that case, put it just below
the div.
For posting, please don't use tabs, use indents of 2 or 4 spaces:
> function makeOptionalDivVisible() {
> document.getElementById('optionalDiv').style.visib ility='visible';
> document.getElementById('optionalDiv').style.heigh t='500px;'
> document.getElementById('optionalDiv').style.overf low='auto';
> document.getElementById('optionalDiv').style.displ ay='block';
If using a function multiple times, it's better to replace it with a
variable but not critical. Also, test for functionality first:
if( a = document.getElementById('optionalDiv')) {
// a.style.visibility='visible';
a.style.height='500px';
a.style.overflow='auto';
a.style.display='block';
> }
> </script>
> <a href="#optionalDiv" onclick="makeOptionalDivVisible();">More
> options?</a>
> <div id="optionalDiv" class="optional">
> <h2>This section is Optional</h2><h4>for more advanced and detailed
> control</h4>
> <hr>
So let's finish the markup so it works:
</div>
</form>
--
Rob
|