Implode function with full JavaScript loop

285 pts.
Tags:
JavaScript
LotusScript
Is it possible to use the @Implode function, as a formula for a column value in a view? I'm creating a Photo Gallery, but I want the thumbnails created in a table, 3 per row. I've set up a column to create the table, and find the appropriate photos, I just can't create rows. I want to do something like this: (y is hard coded to 10, but will be replaced by the number of attachments.) doc:=@Implode("[<script type="text/javascript"> var y=10;z = y; for (i=0;i<y;i++){ if(z % 3 == 1) {document.write("<tr>"); document.write("<TD vAlign="top" width="113"><font face="Arial" size="2"><p><a href="" + ViewURL + ""><img src="" + "/"+DatabaseURL+"/"+ DocumentURL+"/$File/" + @AttachmentNames + """+ " width="100"></a><br>" + @AttachmentNames + "</p></td>); z--; } else {document.write("<TD vAlign="top" width="113"><font face="Arial" size="2"><p><a href="" + ViewURL + ""><img src="" + "/"+DatabaseURL+"/"+ DocumentURL+"/$File/" + @AttachmentNames + """+ " width="100"></a><br>" + @AttachmentNames + "</p></td>}}</script>]"); doc Any help would be great... Cheers -mrg.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Something along these lines will work, but you seem to be creating unnecessary complications for yourself by using JavaScript. Just have your view column code generate the HTML directly, then you will not have this confusion with your quotes (that’s what prevents your current code from working). So the formula might be:

_names := @AttachmentNames;
_count := @Count(_names);
_rowbreaks := @Subset(@Explode(@Repeat({,,</TR><TR>,}; (2+_count)/3); {,}; 1); _count-1) : “”;

“<TR>” + @Implode({<TD valign=”top” width=”113″><img src=”/} + @WebDBName + {/0/} + @Text(@DocumentUniqueID) + {/$FILE/} + @AttachmentNames + {” width=”100″></td>} + _rowbreaks; “”) + {</TR>}

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Mrg
    Genius! That's exactly what I wanted to do. I can't say that I completely understand the code, but it definitely works. I'm gonna have to spend some time dissecting it. Thanks!
    285 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following