285 pts.
 Implode function with full JavaScript loop
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.

Software/Hardware used:
ASKED: February 12, 2008  2:58 PM
UPDATED: November 9, 2012  4:35 PM

Answer Wiki:
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>}
Last Wiki Answer Submitted:  November 9, 2012  4:37 pm  by  Michael Tidmarsh   11,380 pts.
All Answer Wiki Contributors:  Michael Tidmarsh   11,380 pts. , AGuirard   520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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 pts.