Jul Posted March 4, 2004 Posted March 4, 2004 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
Garry Claridge Posted March 4, 2004 Posted March 4, 2004 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
Fenton Posted March 4, 2004 Posted March 4, 2004 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?
Mariano Peterson Posted March 4, 2004 Posted March 4, 2004 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?
Garry Claridge Posted March 4, 2004 Posted March 4, 2004 It is true that WebCompanion does not process CDML between html comment tags However, I've never really felt the need to use html comment tags around Javascript. All the best. Garry
Recommended Posts
This topic is 7907 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 accountSign in
Already have an account? Sign in here.
Sign In Now