Jump to content

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

Recommended Posts

Posted

Hi

First post so please be kind... (!)

I am currently hammering through Filemaker Pro 6 Web Development in conjunction with a live project (I am a fool to myself). My background is the web side rather than Filemaker and I am using my experience with Javascript & HTML to beef up what I can achieve with CDML.

I may be going about this completely the wrong way, so please step in at any time...

I need to set a 'month start date' and 'month finish date' for a calendar using a calculated result (from a javascript) and an inline... phew!

This is what I have placed in the body of the html file:

<script language="JavaScript">

document.write("[FMP-InlineAction: -db=DBNAME, -lay=LAYOUTNAME, -RecID={CurrentRecID}, MONTH START DATE="+stDate+", MONTH FINISH DATE="+fnDate+", -edit][/FMP-InlineAction]");

</script>

Should this work?

I am getting no response at the filemaker end, ie the record is not being updated. When I do a simple javascript alert of the same string the alert box is blank indicating a blank string. Also the html source looks like this when viewed

<script language="JavaScript">

document.write("");

</script>

btw, the variables stDate and fnDate have been tested separately and do exist

And I know that spaces are not supposed to be used in CDML (or any web stuff really) but I'm working with a filemaker developers db's. Therefore not much control. Anyway using this method without Javascript (ie hard coded values) works.

Has anyone any ideas as to what I am doing wrong?

Can this be done?

Is there another way of doing it?

TIA

Matt

Posted

Anatoli , thanks for the quick reply. Having read a load of posts on this forum I am honoured to have your attention!!

Maybe I am going about this the wrong way then. Let me explain what I am trying to achieve.

User enters section of site on a login page

User enters 'username', 'password' and clicks login

User is validated and is shown calendar for current month with various events particular to that user

The filemaker db's that are used have been created by a filemaker developer already and I am following his lead - at the moment.

He has a layout that displays the users bookings that month based on a User ID and Start/End Date for the month.

I am using this layout to do the same on the web page.

ie User logs in, I do a find for that username/password combo.

The next bit is where I may be wrong in my approach. I need to set the start/end dates of the month before returning the months events to be sure the layout is set to the current month and I return the current values for that month.

Sooo... when user clicks login, format file returns correct User ID and I use this page as an intermediate 'logging you in...' screen where I place an Inline that sets the start/end date of the current User ID... the page is set to refresh on 1/2 seconds to the next format file which does a find on the same layout with the same User ID with the start/end dates set correctly and thus displaying the correct month.

It seems a long winded way of doing things , but it is how my mind is working at the minute!!

I cannot do a login (-find) and an -edit at the same time so I thought the intermediate file would be a good stepping stone to perform the -edit.

I need to set the current month's start/end date at login as the user can flick between months while within the calendar section. Therefore when logging out the start/end days may be different from the current month's when logging in next time.

Does this make sense?

Do you need to see the html page?

Any help gratefully received!!!!

TIA

Matt

Posted

"The filemaker db's that are used have been created by a filemaker developer already and I am following his lead ..."

"The next bit is where I may be wrong in my approach. "

"...to be sure the layout is set to the current month..."

Well, instead of following the lead of someone who may well understand peer-to-peer solution design but whose knowledge of web desing may be lacking, you might try having just one layout in your db file which is devoted strictly to the browser solution. Common name choices for this layout are "web" and "cgi" (e.g. name="-lay" value="cgi"). That layout should have all the fields of that db file which are pertinent to the web solution. The only thing looking at that web dedicated layout is another computer, vis a vis a browser. There is no need to navigate through peer-to-peer designed layouts.

Obviously, you are familiar with web design so your format files are basically HTML. What ever fields/data you want to display at any given time are similarly controlled through the use of the CDML tags.

BTW, do you have a copy of the CDMLRD? It is very useful.

Posted

"...you might try having just one layout in your db file which is devoted strictly to the browser solution...There is no need to navigate through peer-to-peer designed layouts."

"BTW, do you have a copy of the CDMLRD? It is very useful."

I do have the CDMLRD thanks and yes it is very useful.

I appreciate your advice, the book I am referencing advises the same thing, 'web' layouts and I am in the process of moving over to them.

At this point I am still stuck with the bigger picture which is either about my approach to the login/show calendar events and/or the use of Javascript with Inline Actions.

I would post the URL but I'm on dynamic IP so there wouldn't be much point as it may have changed by the time you read this (2hr cutoff/reconnect/newIP/aarrgghh!)

Has anyone got a clue? Do you need more info?

TIA

Matt

Posted

I'm not an expert at web in general, and JavaScript in particular. But one possible "gotcha" here is that you are referencing the -recid in your Inline; which you must do with -edit.

This means that whatever form/link called this page would have had to -find for that record. Unless I guess it's a global or universal unstored calculation, in which case a -findany would do.

But I don't believe a -view command will return a record id. So it may be the page that is calling this page, rather than an error here (which is also possible, but I don't see it). To test, why don't put a regular FileMaker field into that Inline, and see if you get anything. That would narrow it down to the JavaScript.

If you still get nothing, then it's probably the page calling this one (my guess).

Posted

Thanks for the info Fenton

I am calling a -find from the first page and then using the -recid to edit with the Inline. I have also simply placed string values as the dates (ie 01/06/2003 and 30/06/2003) in the Inline and that works (so for the month of June... I'm fine!)

I'm not totally understanding Anatoli's comment but I am guessing that he is saying that Inlines and Javascript do not mix.

Therefore I guess I need another approach. Can I set a token via Javascript and the use an inline?

I'm struggling here...

TIA

Matt

Posted

I believe that is what Anatoli is saying, so the same would hold for a token/Javascript/inlineaction.

browser processed routine

server processed routine

Mixed metaphors can be problematic.

Posted

Thanks again for the quick reply

I am assuming my general approach is ok as no-one has picked up on that so far...

1. login (-find)

2. set date (-edit)

3. refresh page (-find)

An idea then could be to use a hidden form value. Change the value dynamically via javascript, then submit the form (via javascript?)

My Javascript knowledge is OK, but for some reason I cannot think of the way to submit the form using javascript rather than by the user clicking a submit button!!

Can I do it automatically?

Sorry, I am thinking out loud, I should look into it myself... l8r

... Matt

Posted

RE: <script language="JavaScript">

document.write("[FMP-InlineAction: -db=DBNAME, -lay=LAYOUTNAME, -RecID={CurrentRecID}, MONTH START DATE="+stDate+", MONTH FINISH DATE="+fnDate+", -edit][/FMP-InlineAction]");

</script>

Can be broken into simple logic.

Data are send to browser and BROWSER is interpreting them like: <script language="JavaScript">

document.write == tell browser JS engine, that it should put on screen following data......

[FMP-InlineAction: -db=DBNAME, == tell WebCompanion SERVER to ignore normal database processing inclusive of pointers etc. and process separately this Inline code.

That can be a problem.

Another problem is if you have comment tag <!-- JS --> around JS code and WC ignore that JS

But major problem I see in the "document.write". You don't want browser to write something to screen, but force WC to process CDML tags.

Posted

Like so many things one can one often can find answers already posted right here on the CDML Forum if one will perform basic searches. I don't know if you will find this will be useful or not.

Posted

At the risk of being "one guy with very dark sunglasses leading another," I believe it's a timing problem. I'm not an expert, but basically FileMaker CDML tags are populated first, then JavaScript executes.

So your "stDate" is not going to have a value, if you're setting it on this page, with some other JavaScript (which you haven't show us).

In order to set a value with JavaScript into a FileMaker field, you have to set it into the form as it is submitted. Something like this (not tested, and possibly wrong; but worth a try:-/

<html>

<<head>

<script language="JavaScript" type="text/javascript">

function setStDate() {

StDate = whatever to set the date with JavaScript

document.forms[0].elements[4].value=StDate;

document.forms[0].submit();

}

</script>

</head>

<body onLoad="javascript: setStDate();">

<form action="FMPro" method="post">

<input type="hidden" name="-DB" value="dbname.fp5">

<input type="hidden" name="-Lay" value="Layoutname">

<input type="hidden" name="-Format" value="ResultPage.htm">

<input type="hidden" name="-recid" value="[FMP-CurrentRecID]">

<input type="hidden" name="StartDate" value="">

<input type="hidden" name="-Edit" value="">

</form>

</body>

</html>

Posted

Matt,

As Anatoli said, the CDML tags are processed by the Server, before they reach the Browser where the JS is processed. That is why the doc.write is empty when viewed as Browser source.

To achieve what you are after you will need to pass the "stDate" and fnDate" values to the Server for processing. This can be done by using Tokens.

Firstly the Tokens will need to be assigned in the preceeding page with either the construction of a URL or a Form.

The CDML/InlineAction would look something like this:

[FMP-InlineAction: -db=DBNAME, -lay=LAYOUTNAME, -RecID={CurrentRecID}, MONTH START DATE={CurrentToken:1}, MONTH FINISH DATE={CurrentToken:2}, -edit][/FMP-InlineAction]

I've never tried an "-edit" from an InlineAction so I don't know what to expect.

All the best.

Garry

Posted

Looks as if Fenton posted while I was composing my reply.

What he has shown is a method for assiging Field values using Javascript. A similar method can be used for assiging values to Tokens. For example:

<html>

<<head> 

<script language="JavaScript" type="text/javascript">

                 function setStDate()      {

                        StDate = whatever to set the date with JavaScript

                        document.forms[0].elements[4].value=StDate;

(OR                  document.myform.elements["-Token.1"].value = stDate;)

                        document.forms[0].submit();

                        }

</script>

</head>



<body onLoad="javascript: setStDate();">



<form name="myform" action="FMPro" method="post">

<input type="hidden" name="-DB" value="dbname.fp5">

<input type="hidden" name="-Lay" value="Layoutname">

<input type="hidden" name="-Format" value="ResultPage.htm">

<input type="hidden" name="-recid" value="[FMP-CurrentRecID]">

<input type="hidden" name="-Token.1" value="">

<input type="hidden" name="-Edit" value="">

</form>



</body>

</html>

I've reused Fentons code smile.gif

Good Luck.

Garry

Posted

Thanks for your replies people, much appreciated... GMT meant I was in the land of nod while you were all working

I'll try the 2 approaches today and let you know how I get on.

Thanks again

Matt

Posted

Thanks for your posts they have been enlightening

I tried this...

perform login on first page

on format page, set 2 hidden form values (start/finish dates) via javascript

automagically submit form via javascript

format file displays the correct calendar info

I also tried the following...

set values for 2 tokens (start/finish date) on the login page using javascript

user submits the form and perform the login passing the tokens with the form

perform an inline on the next page using the tokens passed.

refresh browser using meta tag

format file displays the correct calendar info

They both work but can anyone tell me if one method more advisable?

Thanks again

Matt

Posted

I don't know that, but be sure to check for JavaScript enabled in browser before you will depend on any JS result.

It can be something like:

<SCRIPT language="JavaScript1.2">

top.location.href = "yourJSpage.html"

</SCRIPT>

<NOSCRIPT>

You need JavaScript ON for this page(s)

...put URL for new start here...

</NOSCRIPT>

  • 1 month later...
  • Newbies
Posted

Hi all,

Continuation with this thread !!!!

Is there a way to set a value with JavaScript into a FileMaker field, without using form.

like using in the the link

<a href="databasename&-skip=something&-find">Go</a>

i want to set the value of -skip using javascript !!!

can i do this :

-sat

  • Newbies
Posted

Hi Garry,

I am sorry, the solution which you gave me doesn't seem to work.

I wonder if i am making a mistake.

I am not getting the "Go" hyperlink !!!!

-sat

  • Newbies
Posted

Thanks !!!

I guess i made a mistake with the quotes !!!

However, my problem seems to stay.

It is like this. I have a input box before this Go hyperlink.

and I want to enter a value (record number ) in this box and when I click on the Go link I want to go to this record.

So, I want to set the value in the input box to -skip= ??

I tried using Javascript , but in vain !!!

here is my code....

<script language="JavaScript">

function skipRecord() {

var rec = RecordNumber.value -1;

return rec;

}

</script>

<script>

skip_value=skipRecord();

document.write('<a href="fmpro?-db=databasename&-format=formview.html&-max=1&-skip='+skip_value+'&-find" >GO</a>');

</script>

I have tried all combinations...Any suggestions :?

-sat

Posted

You can use a Form and have the Javascript replace the value of the "-skip" tag, then have it submit the Form. For example:

function skiprec()

{

document.myform.elements["-skip"].value = document.otherform.enterval.value ;

document.myform.submit();

}

You could also use "document.location = xxxxx" in the Function. With this method you could use a URL.

Don't forget to use the "-lay" tag in you URL.

Good Luck.

Garry

This topic is 7873 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.