May 28, 200223 yr 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
May 29, 200223 yr 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.
May 29, 200223 yr 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.
May 29, 200223 yr 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">
May 30, 200223 yr 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
May 30, 200223 yr 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.
May 30, 200223 yr 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
June 3, 200223 yr 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.
June 3, 200223 yr 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