PDA

View Full Version : The (sliding) hidden and open text box



dakedee
01-04-2007, 10:07 AM
Hi All,

I just have a little question to ask.

I wonder how to do the sliding hidden and open text box like:

If you go to Youtube.com and look at the forum board, when you click on "Post text comment" or "reply" or "discard", there shows a textbox or close a textbox without having to load another page.

I have been trying many ways such as CSS and some javascript but the results were not good enough :(

I'm not sure if this Javascript or DHTML or other?

Please anyone let me know, and if you know a good open source to be suggested, that would be very thankfull :)

Many Thanks!

Chad


P.S I'm not sure if I'm posting this at the right forum (as I dont know what the technich is), if wrong, I'm sorry, please also let me know, thanks.

mburt
01-04-2007, 11:48 AM
<script type="text/javascript">
function display(id) {
var obj = document.getElementById(id)
if (obj.style.display == "none") {
obj.style.display = "block"
}
else {
obj.style.display = "none"
}
return false
}
</script>

And use it on any two objects.
For example:

<input type="button" value="Show/Hide" onclick="display('box1')">
<br><div id="box1" style="padding:2px;border:1px solid black;display:none">Text to be displayed</div>

dakedee
01-08-2007, 10:47 AM
Thanks mburt. it works! :)