Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Formatting my results page

Featured Replies

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

Welcome back smile.gif

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

  • Author

Thanks for the quick reply! - i will let you know how I go.

Cheers

Halbj

  • Author

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.

You can do something like this:

<script>

   sCat = "";

[FMP-Record]

   if (sCat == "[FMP-Field:category]")

      {

      document.write("<tr><td>&nbsp;</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

  • Author

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

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

  • Author

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.

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

  • Author

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

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

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.

  • Author

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

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

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.