View Full Version : Dynamic Ajax Content Script: How to close all div's but current

06-07-2006, 03:08 PM
Script: Dynamic Ajax Content: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

Usage: I am using the Dynamic Ajax Content Script to show answers to a list of FAQs. For example,

h2><a href="javascript:ajxCall('faqs/busloan.html','faq1');">How can I apply for a business loan?</a></h2>
<div id="faq1"></div>

<h2><a href="javascript:ajxCall('faqs/creditcards.html','faq2');">Do you offer credit card processing services?</a></h2>
<div id="faq2"></div>

Problem/Question: Seeing that the dynamic content is not loaded in the same place, the new content does not replace the previous, thereby leaving multiple answers open without a way to close them. Is there as simple way to close all other divs when you click on a new one? Would appreciate any help...thanks!

06-09-2006, 05:52 AM
Firstly, note that I've removed the link to ecodebank.com, as I don't recall granting them permission to copy our scripts onto their own site.

Regarding your question, the easiest way is actually to just specify the same DIV (ie: faq1) as the DIV to load the ajax content into in each case. So the 2nd link would look like:

<h2><a href="javascript:ajxCall('faqs/creditcards.html','faq1');">Do you offer credit card processing services?</a></h2>
<div id="faq2"></div>

06-09-2006, 02:05 PM
Hi thanks for your reply. Yes, I think I understand what you mean and why it would work. But, I really don't know much about scripting. I tried to research passing and setting variables and figure you do this with an onclick that calls a function but I just wasn't able to get any part of it working...I am just too much of a scripting newbie. Would you be willing to show me exactly what I need to do to implement? Thanks so much! Janet