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.

Featured Replies

In another thread, garrycl says that

var textInput = "[FMP-Field: course_materials]";

will assign the field's data to a JavaScript variable, but I can't make it work. If I write

var textInput = "[FMP-Field: course_materials]";

document.write(textInput);

I get [FMP-Field: course_materials] and not the field contents. Any suggestions?

If I could crack this, then I could use JavaScript's GREP on displayed data and that would be very powerful.

Thanks

Doug

remove the comment tags from your javascript. (that hide you JS from old browsers)

WC ignores anything in comment tags.

Lasso gets round this with the HTML_Comment tag which is replaced with HTML comments after the contents have been processed.

smile.gifcool.gif

  • Author

Excellent! Thank you scratchmalogicalwax! I have a meeting in a few minutes and will pass this great news on to my clients and then will polish up the JS regular expression to change simple URLs to working links and post it here.

I don't think that I'm overstating that this opens up the chance to really control the on-screen appearance of data without resorting to FMP's feeble text manipulation tools. I'm excited.

Wouldn't you know, though, that simple good practise (aka a historic kludge) would be the culprit.

  • Author

As promised, the JS to convert a all occurrences of URLs

(i.e., http://someplace.com/wally.htm)

to links

(i.e. <a href="http://someplace.com/wally.htm">http://someplace.com/wally.htm</a>)

<script type="text/javascript" name="activateURLs">

Have you tried the Javascript "string.link()" function?

document.write("[FMP-Field:course_materials, Break]".link("[FMP-Field:course_materials, Break]"));

I haven't used this for a long time. We had a thread, early last year, which included some of this. Probably a bit hard to find now.

All the best.

Garry

  • Author

Thanks for the suggestion, garrycl. I'll check that out for sure. I've used JavaScript a fair bit for manipulating images and the occasional control but never before for text diddling--no reason to.

I'm an interface guy rather than a programmer guy but will program if that is what's needed to make things look and work right. I've worked in FMP and the web before (a fair bit) but have never used the two together. The process seems to be riddled with gotchas but every once in awhile something really interesting pops up--like using JS as FMP's missing programming language.

Yes, JS and CDML work very well together. I have just finished a job where we have dynamic and inter-dependent drop-down menus.

All the best.

Garry

FYI, a work around for the comment tags problem. Use an FMP-Include tag to include a file with just the opening comment tag. The comment tags will then show and the web companion will still process the cdml tags in your java script.

  • Author

Thanks dmartins, and a favour--

-could you show me an example of "Use an FMP-Include tag to include a file with just the opening comment tag. "

I grasp the concept but don't know how to do it.

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.