Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Shared table tags with Unverified Perl

I have a two cell table, where the first <td> tag contents is dependent on answers to a previous question and the second <td> tag is consistent, regardless of the answers. The intent is to show the second <td> tag content a grand total of one time in the code since it's shared content.

I had code that looked like this, but it keeps breaking. Any suggestions?

[%Begin Unverified Perl
if(VALUE("q1") < VALUE("q2"))
{return "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td> Content A </td>";}
elsif(VALUE("q1") == VALUE("q2"))
{return "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td> Content B </td>";}
elsif(VALUE("q1") > VALUE("q2"))
{return "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td> Content C </td>";}
End Unverified%]

        <td class="label"> Content the same regardless of q1/q2 relationship </td>
    </tr>
</table>
asked Dec 20, 2018 by WTW_cal Bronze (1,535 points)
Not repeating code is a great standard to hold yourself to.  Naturally anything that is being returned in all three cases can be pulled out of the unverified Perl.  I would probably pull the "<table><tr><td>" code out and place it above the unverified Perl block, and pull the "</td>" code and place it below the unverified Perl block like you've done with the second table cell.

I'm not sure what you mean by the code breaking, though.  What incorrect behavior have you seen?

Your answer

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...