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

Using Javascript to insert token value

Featured Replies

Hi,

I am trying to combine javascript with CDML.

On the first page the user enters some values which are stored as tokens. I pass those values in the link to the second page, and then to the third. On the third page I have two empty fields from filemaker db, which I want to populate with the passed values if the user clicks button.

I am a little familiar with javascript, but I do not know if it is possible to combine CDML and javascript???

I'll appreciate any help.

Thank you

Jul

Here is the CDML method:

<input type="hidden" name="myfield" value="[FMP-CurrentToken:0]">

etc.

Here is the Javascript method:

document.myform.myfield.value = "[FMP-CurrentToken:0]";

CDML works well with Javascript. Just remember that WebCompanion processes the CDML first, hence tags are replaced with data. The Javascript is processed after the page reaches the browser, hence the CDML tags have already been converted to data.

All the best.

Garry

I'll just add one little thing, which tripped me up at first. Normally, esp. in the past, they always tell you to enclose your JavaScript code in comments <!-- code -->, because really old web browsers couldn't read it, so it would just be displayed as text on the page.

But that stops all HTML processing, which stops [FMP-CurrentToken:0] from being processed also. So, basically if you want to mix CDML in JavaScript you can't put HTML comments around it. These days you'd be hard pressed to find a browser that can't handle simple JavaScript, so there's no real problem with going commentless.

Is that true Garry?

I thought the [FMP-CurrentToken:0] was replaced on the server side, before any HTML ever got back to the client. So by the time the client-side JavaScript is run,

document.myform.myfield.value = "[FMP-CurrentToken:0]";

would look more like:

document.myform.myfield.value = "xyz";

Or maybe the problem was that the "<!--" tag also works as a comment for CDML, thereby commenting out all the JavaScript from the CDML parser?

It is true that WebCompanion does not process CDML between html comment tags frown.gif However, I've never really felt the need to use html comment tags around Javascript.

All the best.

Garry

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.