PDA

View Full Version : If Else Syntax



RHDxSPAWNx
02-16-2008, 01:28 AM
Ok I have a problem..I made my own lil Folder link.

andrei_c
02-19-2008, 09:23 PM
Hi RHDxSPAWNx,

You can't achieve this by using template language alone. You will need a combination of dax and javascript here. The IF syntax is very simple:

<dax:if(condition)>
...
<dax:else>
...
</dax:if>

...however, the condition can only be one field or macro variable. The only test possible is one that checks if the field is empty, or if macro variable is "true".

E.g.:
<dax:if(composer)> - tests if Composer field has anything in it.
<dax:if(single)> - tests if Single checkbox is checked.

What you need is approximately this:

<div id="acdc" style="display:none"> .... <div>
<div id="notacdc"> .... </div>
<script type="text/javascript">
var a = '<dax:artist/>';
if (a=='AC/DC') {
document.getElementById('notacdc').style.display=' none';
document.getElementById('acdc').style.display='';
}
</script>