WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 How to add more then one Answer on this tut on Fri Oct 21, 2011 4:01 pm

Matti


Registered Member
Registered Member
I'm using this tutorial www.webartzforum.com/t903-making-show-hide-content by: Unknown Data, Showing and hiding content on mouse click! but i can't figure out on how to add more answer...

I have done it like this but it doesn't work.

Code:
<a onclick="javascript:ShowHide('HiddenDiv_1')" href="javascript:;" >Question</a>
<div id="HiddenDiv_1" style="DISPLAY: none" >Answer</div>
<div id="HiddenDiv_2" style="DISPLAY: none" >Answer</div>
<div id="HiddenDiv_3" style="DISPLAY: none" >Answer</div>


<script language="JavaScript">function ShowHide(divId){if(document.getElementById(divId).style.display == 'none'){document.getElementById(divId).style.display='block';}else{document.getElementById(divId).style.display = 'none';}}</script>




RockerMan


WebArtz Technician
WebArtz Technician
You should be able to just add it because there are no elements in the JavaScript that defines the amount of divs, just be sure to give it the same ID


_________________


No support via. PM, as they will just be deleted
http://www.graphics-post.com/

Matti


Registered Member
Registered Member
I don't know what you mean but when I put the code like this...
Code:
<a onclick="javascript:ShowHide('HiddenDiv_1')" href="javascript:;" >Question</a>
<div id="HiddenDiv_1" style="DISPLAY: none" >Answer 1</div>
<div id="HiddenDiv_1" style="DISPLAY: none" >Answer 2</div>
<div id="HiddenDiv_1" style="DISPLAY: none" >Answer 3</div>


<script language="JavaScript">function ShowHide(divId){if(document.getElementById(divId).style.display == 'none'){document.getElementById(divId).style.display='block';}else{document.getElementById(divId).style.display = 'none';}}</script>


it gives me only one answer and not 3-5 ect...

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum