Template binding issue

Here’s what I am trying to do…

I have a slot displaying FAQs. When I click on one of the questions it should display the answer below the question within the same slot. I am not redirecting to a new page here onclick event.

Here a section of the html…
<div align=“left”>
<a href="#" >
Q. #field(“question”) ?
</a>
</div>

#if($answerValue != “0”)
<div >
#field(“answer”)

	  &lt;/div&gt;

#end

Also when I click on the same question again, the answer field should disappear.

Here is the binding I am using to achieve this
$answerValue = $rx.location.getFirstDefined($sys.item,‘rx:answer’, ‘0’)

I am not sure my approach is right. Can someone guide me through this issue?

Thanks
Pallavi

Can you repost this with the HTML inside HTML tags (use the button in VBulletin that looks like <> ).

We cannot read it as you’ve posted it.

Dave

I am sorry about the html…

This is a repost. I have rephrased my problem here

Here’s what I am trying to do…

I have a slot displaying FAQs. When I click on one of the questions it should display the answer below the question within the same slot. I am not redirecting to a new page here onclick event.
Also when I click on the same question again, the answer field should disappear.

I am not sure my approach is right. Can someone guide me through this issue?

My html looks similar to the following.


<head>
    <title>#displayfield("displaytitle")</title>
	<meta content="Percussion Rhythmyx" name="generator"/>
	<script language="javascript" src="${rxs_navbase}/js/showhideDIV.js" type="text/javascript">;</script>
</head>
 <body style="background-image:none; background-color:#ffffff;">
    
     <div align="left">
    		<a href="#"  onclick="javascript:toggleDiv('showhideDIV');return false;">
        	   #field("question") 
        	</a>
	  </div>
	  

    	  <div id="showhideDIV" style="display: none;" >
    			#field_if_set("" "answer" "" )
		  </div>
		 
 </body>

Thanks
Pallavi

I’m a little confused. It seems like what you have should work… are you getting any specific error that’s stopping this from working?

No, I dont get any error but the script tag disappears for some reason. So when I click on link nothing happens.

Try moving the script tag from the page template to the global template, or select the “None” radio button on the page template in the section to determine which global template it uses.

Its a Snippet template as I am displaying the content(FAQs) in a slot. I dont have an associated page template. The html is for the snippet.

Pallavi,

Andrew is right, you need to move your JS reference to the Global Template.

The header code in a Snippet is only used when previewing the Snippet itself. If you are viewing published HTML or previewing a page including the Snippet, the header is stripped out during assembly. The header code in a Page Template is used the same way.

If you are using a Page Template intended for outputting FAQs, you might want to implement a Global Template specific to that Page Template and include the JS reference in that Global Template.

RLJII

Thanks . That works now

I am still facing a problem. When I insert only one snippet, clicking on the ‘question’ Link displays the ‘answer’ and then when I click again makes the ‘answer’ disappear.

But when I insert 2 or more snippets(each displays one question) no matter which ‘question’ link I click on, it displays the answer in the first snippet. I think I have a vague idea why this happens but I could not figure out a workaround.

I hope I have not created confusion around my issue.

Pallavi,

If you tell us what you think the problem is, we can probably help you more effectively.

When you say

Do you mean that the answer for the first question is being assembled for each question, instead of the answer associated with that question:

Q1
A1
Q2
A1
Q3
A1

Or do you mean that the correct answer is assembled with each question, but when you click on Q3, A1 expands?

RLJII

The correct answer is assembled with each question, but when I click on Q3, A1 expands
So I have
Q1
A1
Q2
A2
Q3
A3

but when I click on either Q1 or Q2 or Q3, A1 expands and not the respective answers

Pallavi,

Sounds like the issue is in the JavaScript and how it decides which block to expand. Does that work correctly in an HTML page not managed by Percussion CM System?

RLJ II