PDA

View Full Version : How do I collapse the answer to a question?


TommyD67
10-22-2012, 05:44 PM
I want to have an FAQ page but I want users to be able to expand and collapse the answers.

domedia
10-22-2012, 06:06 PM
Hi Tommy,

How fluent are you in Javascript and CSS?

Others: Is there a built in DW way to do this?

TommyD67
10-22-2012, 06:32 PM
I am not fluent. I was hoping their was a way to do it through the tool. I have a problem with saying no to my boss and telling him I cannot do something, so I just figure it out.

domedia
10-22-2012, 07:55 PM
If your DW version has Spry, it should be pretty easy from there too. </guess>


.

edbr
10-23-2012, 02:29 AM
for multiple then a spry accordian would do it i would agree, check jquery also as i dont think this will be built in dw.

here is a working snippet if you want to get creative
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>

<script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "show";
}
else {
ele.style.display = "block";
text.innerHTML = "close the answer";
}
}
</script>
<p>heres a question . if you want to kow the answer to life the universe and everything</p>
<a id="displayText" href="javascript:toggle();">click Here for the answer</a>
<div id="toggleText" style="display: none"><h1>42</h1></div>
</body>
</html>

edbr
10-23-2012, 02:38 AM
infact some useful explained ideas for you using jquery.
http://www.randomsnippets.com/2011/04/10/how-to-hide-show-or-toggle-your-div-with-jquery/#more-336