halbj Posted April 24, 2003 Posted April 24, 2003 Hi I want to be able to simulate a 'Sub-Summary When Sorted By...' on my results page. I want them sorted and summarized by category ie. Cat1 record record record Cat2 Record Record..... etc I was adivsed that this could be done with a java script, to do the summarizing, post CDML processing. Is this possible? Does anyone know of such a script?? Be cool Halbj
Garry Claridge Posted April 24, 2003 Posted April 24, 2003 Welcome back OK, If you sort by "category" you could do something like this: <script> sCat = ""; [FMP-Record] if (sCat == "[FMP-Field:category]") { document.write("[FMP-Field:myfield]<br>"); } else { sCat = "[FMP-Field:category]"; document.write("<b>[FMP-Field:category]</b><br>"); document.write("[FMP-Field:myfield]<br>"); }; [/FMP-Record]</script> Something like this will do the job. All the best. Garry
halbj Posted April 24, 2003 Author Posted April 24, 2003 Thanks for the quick reply! - i will let you know how I go. Cheers Halbj
halbj Posted April 28, 2003 Author Posted April 28, 2003 That works well Garry, Just wondering if the script could be modified to put results fields 1 2 &3 into a table. ie Cat1 <tr> <td>field1</td><td>field2</td><td>field3</td> </tr> Does this make sense? Cheers Hal.
Garry Claridge Posted April 28, 2003 Posted April 28, 2003 You can do something like this: <script> sCat = ""; [FMP-Record] if (sCat == "[FMP-Field:category]") { document.write("<tr><td> </td><td>[FMP-Field:field1]</td><td>[FMP-Field:field2]</td><td>[FMP-Field:field3]</td></tr>"); } else { sCat = "[FMP-Field:category]"; document.write("<tr><td><b>[FMP-Field:category]</b></td>"); document.write("<td>[FMP-Field:field1]</td><td>[FMP-Field:field2]</td><td>[FMP-Field:field3]</td></tr>"); }; [/FMP-Record]</script> All the best. Garry
halbj Posted April 28, 2003 Author Posted April 28, 2003 ...... OK - I got that working with the following code. <script> sCat = ""; [FMP-Record] if (sCat == "[FMP-Field:SectionHeading3]") { document.write("<table><tr><td>[FMP-Field:PrecedentLink]</td><td>[FMP-Field:type1]</td></tr></table>"); } else { sCat = "[FMP-Field:SectionHeading3]"; document.write("<b>[FMP-Field:SectionHeading3]</b><br>"); document.write("<table><tr><td>[FMP-Field:PrecedentLink]</td><td>[FMP-Field:type1]</td></tr></table>"); }; [/FMP-Record]</script> But....... If I try and add "table width" and 'border" attributes to the <table> tag, I get a blank results screen. In addition to this, the field "PrecedentLink" is a calculation that;s result is a string that is '<a "http://10.10.10.10/data">data</a>'. becuase of this I need [FMP-Field:PrecedentLink] to be [FMP-Field:PrecedentLink,Raw]. But when I add the ',Raw' to the tag, I get a blank results page. Any ideas on how I can acheive the raw encoding on the field and the table border? Cheers Hal.
Garry Claridge Posted April 28, 2003 Posted April 28, 2003 Re: "table width" and 'border" attributes to the <table> tag, I get a blank results screen. Check wether you are using " instead of '. Re: <a "http://10.10.10.10/data">data</a> Should be <a href='http://10.10.10.10/date'>data</a> Trying to match " and ' pairs can be a bit of a trap (and a pain). Good Luck. Garry
halbj Posted April 28, 2003 Author Posted April 28, 2003 hmmmmmm... I am still unable to get the 'link' field to process as raw - I still get a blank results page. Here is my code.. <script> sCat = ""; [FMP-Record] if (sCat == "[FMP-Field:SectionHeading3]") { document.write("<table border='1'><tr><td><p>[FMP-Field:PrecedentLink, Raw]</P></td><td>[FMP-Field:type1]</td></tr></table>"); } else { sCat = "[FMP-Field:SectionHeading3]"; document.write("<b>[FMP-Field:SectionHeading3]</b><br>"); document.write("<table border='1'><tr><td><p>[FMP-Field:PrecedentLink, Raw]</P></td><td>[FMP-Field:type1]</td></tr></table>"); }; [/FMP-Record]</script> And here is a sample of the processed page code.. document.write("<table border='1'><tr><td><p><a href= 'http://10.70.10.8/precedents/p61851828.doc'>Food court provision</a></p></td><td>Deed / Agreement</td></tr></table>"); Any ideas? I have tried all combinations of "xx" and 'xx'. Is there a 'general' rule when dealing with them? Cheers Hal.
Garry Claridge Posted April 28, 2003 Posted April 28, 2003 The only thing I can see is this: <a href= 'http://10.70.10.8/precedents/ There is a space between = and 'http. Try removing this to see if there is any difference. Good Luck. Garry
halbj Posted April 29, 2003 Author Posted April 29, 2003 ..Still no good. If I specify 'Raw' my results page is still blank. If I view the source code of the processed page and copy the generated code in the 'document.write("generated_code") ', then paste it into a web page, the browser processes it as requested - wierd?
Garry Claridge Posted April 29, 2003 Posted April 29, 2003 I have had problems with the odd carriage-return in the field. They should not have been there, however some users happened to press return when they finished entering the data. What happens when you do not use "raw". Also, can you use controlled data; that is only one or two records with data you have absolute control over. Good Luck. Garry
Anatoli Posted April 29, 2003 Posted April 29, 2003 Those "odd carriage-return in the field" are worst enemy of JavaScript. For Web serving/displaying I am using another Calculation field with CR filtered out.
halbj Posted May 1, 2003 Author Posted May 1, 2003 when I do not use 'raw' it writes that text to the screen eg <a href='http://10.70.10.8/precedents/p61495362.doc'>Manager & Licensee Guidelines Beer Producer</a> for each record. I am using good data, and always using the same set (of about 95 records) when testing. I am sooo close, yet so far..... H
Garry Claridge Posted May 1, 2003 Posted May 1, 2003 Try this: document.write("<table border='1'><tr><td>" + escape("[FMP-Field:PrecedentLink, Raw]") + "</td><td>[FMP-Field:type1]</td></tr></table>"); I have added the "escape()" function. Also, I have removed the <p></p> tags. Good Luck. Garry
Recommended Posts
This topic is 7947 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now