Visibility...

1

116

I am looking for some info regarding having a button on page load invisible
so I can use another button with a Visible behavior later.

David
 
T

Trevor Lawrence

Do you want the invisible button to later become visible rather than use
another button which is visible ?

If so, it is not difficult but could you give a bit more detail.
 
T

Trevor Lawrence

116 said:
My scripting is limited, and I am trying to clean up some pages that show
DB
results for printing. At the time I click a button to hide some items, I
want a button to for print to become visible.

David,

This code will show or hide the <div> with given id, e.g."hiddenDiv"

I have shown 2 examples. They call the same JS code, but with a different
parameter (the <div> id )

<html>
<head>
<script type="text/javascript">
function showHide(divname){
var a=document.getElementById(divname).style
a.display = (a.display!='none') ? 'none' : 'block'
}
</script>
</head>
<body>

<p>
<input type="button" id="Show" value="Show Hide text"
onclick="showHide('hiddenDiv')" />
</p>
<div id="hiddenDiv">
hidden text
</div>

<p>
<input type="button" id="Show" value="Show Hide text"
onclick="showHide('hiddenDiv2')" />
</p>
<div id="hiddenDiv2">
hidden text 2
</div>

</body>
</html>
 
M

Murray

Actually, it does better than that. The page treats the <div> as if it
weren't even there since you have used the display style rather than the
hidden style.

However, it will throw an error if the page doesn't contain those elements
(div#hiddenDiv and div#hiddenDiv2).

And, by the way, you need to actually HIDE those elements with your CSS -

<style type="text/css">
#hiddenDiv, #hiddenDiv { display:none; }
</style>
 
T

Trevor Lawrence

Thanks Murray.

As always you pick up on the details I miss .

But interestingly I did test this code with the <div>s hidden and not hidden
and it seemed to work OK. Clearly I am missing something
 
M

Murray

Oh, it works fine whether the divs are initially display:none or
display:block, but the original post was about starting from the
display:none state, no?

Did you try it if you have omitted one of those elements from the page?

--
Murray
MVP Expression Web


Trevor Lawrence said:
Thanks Murray.

As always you pick up on the details I miss .

But interestingly I did test this code with the <div>s hidden and not
hidden and it seemed to work OK. Clearly I am missing something
 

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

Top