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

search field to token

Featured Replies

is there are way to set the search criteria of one field to a token at time of submission.

1. I would like to state after the results are displayed that 'xx records have been found for the search for ( token) - I know there it the FMP-CurrentFind, but that list all value hidden and other which is not import for the user to see.

NOTE!! I am sure I could capture the resulting field as it returns in the format file, but in this case the field being requests is keywords, so the result is not a single words.

2. I would like as a token as well so I can send it back to the DB to log the search words.

From CDML db:

[FMP-FindValueItem]

What it does

[FMP-FindValueItem] is replaced with the value that was part of the find request that created this page.

[FMP-FindValueItem] must be placed between the [FMP-CurrentFind] and [FMP-CurrentFind] tags.

Syntax

[FMP-FindValueItem: Encoding ]

Parameter(s)

First parameter (optional): Encoding. Use one of the following reserved words:

Raw - Don't perform any encoding

URL - Perform URL encoding

HTML - (default) Perform HTML encoding

Syntax example(s)

Return the current find criteria using an HTML file

Current find request is:<br>

[FMP-CurrentFind]

Field: [FMP-FindFieldItem], Op: [FMP-FindOpItem], Value: [FMP-FindValueItem]<br>

[/FMP-CurrentFind]

<!-- After processing it could look like:

Current find request is:

Field: First Name, Op: begins with, Value: Joe

Field: Last Name, Op: equals, Value: Doe

-->

Other tags that are required

[FMP-CurrentFind], [/FMP-CurrentFind]

See also

[FMP-FindFieldItem], [FMP-FindOpItem]

You can use some Javascript to do this. For example:

<script>

function addtoken()

{

document.myform.elements["-token"].value = document.myform.myfield.value ;

document.myform.submit();

}

</script>

</head>

<body>

<form name="myform" action="FMPro" method="POST" onsubmit="Javascript:addtoken(); return false;">

<input type="hidden" name="-db" value......

.....

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

Enter Data: <input type="text" name="myfield" value="">

.......

The Javascript function makes the value of the token equal to the value of "myfield". Then it submits the Form.

Hope this helps.

Garry

  • 2 weeks later...
  • Author

This looks like it will do it but I get '[object INPUT]' as a result. Any ideas?

I don't know what '[object INPUT]' is!

Did you leave a ".value" from the assignment?

Show us your code.

All the best.

Garry

  • Author

Here is the code

------------------

<script>

function addtoken()

{

document.eyeSearch.elements["-token"].value = document.eyeSearch.i_keywords ;

document.eyeSearch.submit();

}

</script>

Yes you did leave ".value" off the assignment.

Should be:

document.eyeSearch.elements["-token"].value = document.eyeSearch.i_keywords.value ;

All the best.

Garry

What an eye!

Garry, you are the JS Czar! laugh.gif

  • Author

Perfect thanks.

One last question, does the following script make sense if I want to handle to values?

<script>

function addtoken()

{

document.eyeSearch.elements["-token"].value = document. eyeSearch.i_keywords.value ;

document. eyeSearch.elements["-token.1"].value = document. eyeSearch.i_Artist.value ;

document. eyeSearch.submit();

}

</script>

Yes, that should work.

All the best.

Garry

  • 2 months later...

The answer above is exactly what I need, but mine isn't working.

Could it be because I'm using an include file? I put the <script> info in the main page, but the OnSubmit info in the include file. Here is my code that is not working:

In the main file:

<link href="style.css" rel="stylesheet" type="text/css">

<script>

function addtoken()

{

document.myform.elements["-token.0"].value = document.myform.month.value ;

document.myform.elements["-token.1"].value = document.myform.year.value ;

document.myform.submit();

}

</script>

</HEAD>

In the include file:

<form name"myform" action="FMPro" method="Post" onsubmit="Javascript:addtoken(); return false;">

<INPUT TYPE="hidden" NAME="-DB" VALUE="calendarmonth.fp5">

etc...

<input type="hidden" name="-token.0" value=""><select name ="Month">

<option value="1">January</option>

<option value="2">February</option>

</select>

<input type="hidden" name="-token.1" value=""><select name ="Year">[FMP-Option: Year, List=Years]</select>

<input type="submit" name="-find" value="View Month">

My knowledge of JS is limited to copying/pasting code like this, so thanks for your help!

To tell if the "include" is working you can view the "Page Source" in the browser. From this you will be able to see if the FM data, i.e. Years, has been entered and the other html is present.

What do you mean by "not working"? What happens?

Good Luck.

Garry

The include is working. I can see that the FileMaker elements are being filled in.

By "not working," I mean that when I hit the Submit button, the values for Month and Year are not being set as tokens. I have

Current Token:0: [fmp-CurrentToken:0]

Current Token:1: [fmp-CurrentToken:1]

on the Format page, and they are blank after I press the submit button. So I'm guessing there's something wrong with my code. I am currently avoiding the main/include issue by having all of the js code on the same page, and I still can't pass the tokens from the submit button.

I did notice that I had <form name"myform" so I changed it to <form name="myform"

Unfortunately that did not solve the problem.

I changed two things, and now it is working:

1. Case sensitive. I had "Years" in one place, but "years" in another. Now I have "years" for both.

2. Hard-coded the <options> instead of using a FMP value list.

Create an account or sign in to comment

Important Information

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

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.