PDA

View Full Version : dot buttons - with drop down text


richcodesign
04-11-2011, 11:17 AM
Hello,
I hope you can help with the following:

I want a page on my site that allows visitors to choose the best option for them. It will ask them a question and they will select 'yes' or 'no' and relevant information will appear to answer their question.

for example:

Q. Do you have cement?
A. 'Yes' button
Drop down text. 'please proceed to question 2'

OR

Q. Do you have cement?
A. 'No' button
Drop down text. 'this is not suitable for you, please visit our sister website'

I hope this makes sense, I couldnt find an example to post.

Thank you for your help in advanced.

johnMoss
04-11-2011, 02:55 PM
In your header add this:
<script>
function sw(y,x){
t=document.getElementById(x).style
t.visibility=(y=='on')?'visible':'hidden'
}
</script>

In your CSS (or <style>...</style> in your header) add this:

#div1,#div2 {visibility:hidden;}


In the body add this:
<button onclick=sw('on','div1')>Show</button>
<div id=div1>
Text of div1
<button onclick=sw('off','div1')>Hide</button>
</div>

<button onclick=sw('on','div2')>Show</button>
<div id=div2>
Text of div2
<button onclick=sw('off','div2')>Hide</button>
</div>


Name the divs as you will, put them where you want, and add your text as placed above. This will open & shut the text boxes when the respective button is clicked.

richcodesign
04-11-2011, 04:31 PM
Thank you so much, Its just what i wanted to achieve.... Perfect.
:-D8):lol:

richcodesign
04-11-2011, 04:34 PM
sorry... just one other thing, Is that code javascript?

johnMoss
04-11-2011, 04:38 PM
you're welcome, glad I could help, and yes, JS...