Forum

Thread tagged as: Question, Problem

If statement

Hi, I have a Block that contains a select field and a repeater. Is it possible to use the ID of the select field outside the repeater in an "if" statement. In my example I want to set a class depending on what is selected from the select field. It does not seem to work if I'm trying to access data outside the repeater.

My example:

<perch:block type="file" label="File">
    <div id="block15">
        <perch:content id="linkType" label="Link Type" type="select" options="Link|link,Button|btn-primary" />
        <perch:repeater id="file" label="File">
            <a href="<perch:content id="file" type="file" label="File" bucket="files" />" class="<perch:if id="linkType" value="btn-primary"  match="eq" />btn btn-primary </perch:if>">   
                <perch:content id="fileName" type="text" label="File Name" required="true" size="xl" />
            </a><br>
        </perch:repeater>
    </div>
</perch:block>
Shawn North

Shawn North 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Sure - see the section "Accessing content outside the repeater" in the repeater docs here: https://docs.grabaperch.com/docs/templates/repeaters/

Awesome thanks!