Jump to content

This topic is 7639 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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

Posted

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?

Posted

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?

This topic is 7639 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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