Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I have a search results page with several lines of records in a table. First I would like to show a checkbox checked or unchecked based on the data in the record. Is that possible?

Next, I would like to have the web user check or uncheck that box, have a submit button at the bottom of the page that will edit the database accordingly.

After playing with it for hours, I'm wondering if it is even possible. I would prefer not to have to have a button at every record that edits it and looses your search results.

Any ideas?

Thanks!

Posted

From CDML database:

CheckBox

What it does

An HTML input type. Used by a browser to display checkbox(es).

This is not a FileMaker Pro tag, This is standard HTML.

Do not include calculation or summary field types on add or update format files, as data can't be entered into these field types.

Syntax

<input type="checkbox" name="Field" value="Data" Checked>Checkbox Label

Field - The name of the field that you want the data to go into.

Data - The information that should be placed into the field.

Checked (optional) - Specifies that the checkbox is checked. If the word "checked" is not present, the checkbox is not checked.

Checkbox Label - The label that the user sees in the browser.

Syntax example(s)

Display checkboxes using an HTML file

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

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

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

<input type="checkbox" name="Country" value="F1">France

<input type="checkbox" name="Country" value="G7" checked>Germany

<input type="checkbox" name="Country" value="I4" checked>Iceland

<input type="checkbox" name="Country" value="U2">USA

<input type="submit" name="-New" value="New Record">

</form>

If that fails, you can use CDML IF Else Endif on the HTML page.

RE: Next, I would like to have the web user check or uncheck that box, have a submit button at the bottom of the page that will edit the database accordingly.

That is easily achieved in Lasso.

In FM you must use scripts, which is bad on web.

It will be possible with JavaScript and arrays filed with FM data.

In short -- you must somehow construct loop through submitted records from single form.

RE: After playing with it for hours, I'm wondering if it is even possible. I would prefer not to have to have a button at every record that edits it and looses your search results.

If you will store your query in Token, you will not loose your search query.

HTH

Posted

Thanks! You got me thinking more productively! (And I found my CDML Reference file)

The If/Else works great to check the box in HTML if it is checked in FMPro.

Now I must find a practical way to update the database for newly checked boxes. I could show a remove button on ones that were checked, and an add button for those to be added to the pick list. I hate to have to refresh the page with every choice, though. Anyone have a javascript to submit in a looping fashion as Anatoli suggested? Is that really diffecult to implement? I suppose it would take forever with lots of records. Could it just submit the checked ones, elegantly?

Also, what is the syntax to set a token to the current find? In the reference file it only shows breaking it down by field. In this case, a user could be searching on many different fields.

Thanks!

Posted

Here is a method using PHP 4.3:

The Listing page:

<html>

<head>

<title>FM Multi Edit</title>

</head>

<body>Hello World<br>

<form action="http://localhost/fmmultied.php" method="POST">

[FMP-Record]

[FMP-IF: yes_no .eq. Yes]

Yes<input type="checkbox" name="yes_no[]" value="[FMP-CurrentRecID]" checked><br>

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

[FMP-Else]

Yes<input type="checkbox" name="yes_no[]" value="[FMP-CurrentRecID]">

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

[/FMP-If]

[/FMP-Record]

<input type="submit" value="Edit">

</form></body></html>

Here is the PHP file "fmmultied.php":

<?php

$rec_ids = $_POST["rec_id"];

$yes_nos = $_POST["yes_no"];

for ($i = 0; $i < count ($rec_ids) ; $i++)

{

if (in_array ($rec_ids[$i],$yes_nos))

{

$result = file_get_contents ("http://localhost:1154/FMPro?-db=combotest.fp5&-lay=multiedit&-format=ok.txt&-error=er.txt&-recid=" . $rec_ids[$i] . "&yes_no=Yes&-edit");

}

else

{

$result = file_get_contents ("http://localhost:1154/FMPro?-db=combotest.fp5&-lay=multiedit&-format=ok.txt&-error=er.txt&-recid=" . $rec_ids[$i] . "&yes_no=No&-edit");

};

} ;

require ("index.html");

?>

I have been using this on OS X.

All the best.

Garry

Posted

Thanks, Garry. Excellent reply!

My HTML is very similar to yours, but I have never used PHP.

This will be hosted on OSX also. Where does the PHP file go, and is OSX ready to take it by default, or does something have to be installed?

Posted

Thanks.

So I save this code as a text file called "fmmultied.php", put it there, and it will work!? (after upgrading).

When this is set up, I will be able to check & uncheck boxes on any number of records in my HTML page, then submit all changes with a click of one button to update the database? Perfect!!

I hope to get it working!

Thanks,

Ken

Posted

After installing the php solution above, when I open Filemaker Pro 6.0 I get an error message that web companion can't use port 80, 'cause it's already in use (by php).

Which one should I change the port on, and what should I change it to? Will it affect their interaction, or the interaction between Filemaker & the web?

Thanks,

Ken

Posted

Usually Apache will run on port 80. Filemaker can be changed to any unused port. Often Filemaker will be set to port 591. (You can see from my code that I use port 1154 for Filemaker.)

All the best.

Garry

Posted

Hi, Ken! The port changing can be done in FileMaker's Web Companion configuration. I recommend :591 as Garry mentions unless you disable Apache (if MacOSX, SysPref > Sharing > PersonalWebSharing unchecked. I believe FileMaker has registered :591 port for FMP as an alternate to :80.

http://www.yourdomain.com

http://www.yourdomain.com:80

http://www.yourdomain.com:591

We used :591 for years but it made our URLs clunky so we switched back to :80. The first 2 URLs above are equivlaent; the 3rd one requires the :591 or users will not be able to see your web pages. I forget which ones (<1000?), but lower number ports are registered. I think sometimes people use :8080 for web, too, but as Garry said, any unused port can be used.

If you are running OSX, they give you a great little app called NETWORK UTILITY that will let you port scan your server so you can see what ports it is using. Interpreting what those are being used for can take some time, though, as it is not always obvious. They can be used for all kinds of stuff: websites, various mail, AppleTalk, networking, pinging, etc. When we tried locking down our server as tight as we could, we blocked important services that we didn't realize depended on certain ports being open. We had to re-open a couple when users couldn't connect or get mail even though we left those ports open.

Just be careful what you port scan... it is considered nefarious activity by most server admins since hackers tend to start their mischief that way. Don't be surprised if you port scan someone and they track you down.

Happy computing!

P.S. Me? Organized? LOL! I have to lift by keyboard to see if my desk is still made of wood!

Posted

IMHO -- use always 591 if 80 is not available. FM registered it at IANA for web companion.

Or if on that IP is not running web server on port 80, use 80 for WC.

Or use Web Server Connector and serve WC on 591 to WSC to 80 on web server.

Posted

Thanks for the good info, guys.

I hate to admit it, cause I'm not that kind of guy, but deadlines caused me to scrap the php idea. I'm not one to give up, but I did. I had to do something to get it basically functional. I changed Garry's script to substitute my fields, etc. and I got a couple of errors, repeated for all the records in the found set! How intimidating!

Maybe I'll post some errors later. I pulled another all nighter last night, and I gotta get some sleep!

Thanks again,

Ken

Posted

Thanks, Garry, I appreciate the offer! I'll give you the whole page, in case the javascript is suspect or something. Here's what I've got:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Set Search Results</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript"><!--

<!-- Begin

function Start(page) {

OpenWin = this.open(page, "CtrlWindow", "width=520,height=600,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");

}

// --></script>

</head>

<body>

<h2 align="center"><strong>The WB Network<br>

</strong><font size="3">Set Warehouse Database</font><br>

<font size="4">Search Results Page</font></h2>

<form action="http://localhost/fmmultied.php" method="POST">

<h2 align="left"><font size="4"><br>

<font size="1">Displaying records [FMP-RANGESTART] thru [FMP-RANGEEND] of [FMP-CURRENTFOUNDCOUNT]

records found.<br>

</font><FONT COLOR="#000000"><font size="1">[FMP-LINKPREVIOUS] &lt; Show previous

set [/FMP-LINKPREVIOUS] &nbsp;&nbsp;[FMP-LINKNEXT] Show next set &gt; [/FMP-LINKNEXT]</font></FONT><font size="1">&nbsp;</font></font></h2>

<table width="648" border="5">

<tr>

<td width="100"><font size="2"><strong>Photo</strong></font></td>

<td width="100"><font size="2"><strong>Pick</strong></font></td>

<td width="100"><font size="2"><strong>Unit #</strong></font></td>

<td width="100"><font size="2"><strong>Width</strong></font></td>

<td width="100"><font size="2"><strong>Height</strong></font></td>

<td width="100"><font size="2"><strong>Type</strong></font></td>

<td width="100"><font size="2"><strong>Swing Set Name</strong></font></td>

<td width="100"><font size="2"><strong>Locations[FMP-RECORD]</strong></font></td>

</tr>

<tr>

<td><div align="center">

<p><a href="javascript:Start('[FMP-FIELD: PhotoPage]')"><img src="[FMP-FIELD:ThumbnailName]" border="0"></a><br>

<font size="2"><a href="[FMP-LinkRecID: format=Details.htm, layout=Data Entry]">Details</a></font>

</p>

</div></td>

<td> <div align="center">[FMP-If: Field:Picked .eq. 1]

<input name="Picked" type="checkbox" value="[FMP-CurrentRecID] " checked>

<br>

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

[FMP-Else]

<input name="Picked" type="checkbox" value="[FMP-CurrentRecID]">

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

[/FMP-If] </div></td>

<td>[FMP-FIELD: Unit#]</td>

<td>[FMP-FIELD: Width]</td>

<td>[FMP-FIELD: Height]</td>

<td>[FMP-FIELD: Type]</td>

<td>[FMP-FIELD: SwingSetName]</td>

<td>[FMP-FIELD: Locations][/FMP-RECORD]</td>

<td>&nbsp;</td>

</tr>

</table>

<h5 align="left">Displaying records [FMP-RANGESTART] thru [FMP-RANGEEND] of [FMP-CURRENTFOUNDCOUNT]

records found. <br>

<font size="4"><FONT COLOR="#000000"><font size="1">[FMP-LINKPREVIOUS] &lt;

Show previous set [/FMP-LINKPREVIOUS] &nbsp;&nbsp;[FMP-LINKNEXT] Show next set

&gt; [/FMP-LINKNEXT]</font></FONT>&nbsp;</font></h5>

<h5 align="left">

<INPUT TYPE="submit" VALUE="Update">

<P>

</form>

<br>

</h5>

</body>

</html>

Here's the PHP file:

<?php

$rec_ids = $_POST["rec_id"];

$Picked = $_POST["Picked"];

for ($i = 0; $i < count ($rec_ids) ; $i++)

{

if (in_array ($rec_ids[$i],$Pickeds))

{

$result = file_get_contents ("http://localhost:1154/FMPro?-db=InventoryDatabase.fp5&-lay=Data Entry&-format=Results.htm&-error=error.htm&-recid=" . $rec_ids[$i] . "&Picked=1&-edit");

}

else

{

$result = file_get_contents ("http://localhost:1154/FMPro?-db=InventoryDatabase.fp5&-lay=Data Entry&-format=Results.htm&-error=error.htm&-recid=" . $rec_ids[$i] . "&Picked=&-edit");

};

} ;

require ("index.html");

?>

As I recall, the error was referring to line 8 an 14, I think.

See anything obvious?

Thanks,

Ken

Posted

Ken,

I've found a few errors smile.gif

- A minor html problem: Locations[FMP-RECORD]</strong></font></td>

I would have moved the [FMP-Record] outside of the row tags.

- The "Picked" input tag should be like this:

<input name="Picked[]" type="checkbox" value="[FMP-CurrentRecID]" checked>

Add [] to the end of the name. Also remove the space from RecID] ".

- In the php a variable (Picked) is spelt incorrectly:

if (in_array ($rec_ids[$i],$Pickeds))

should be:

if (in_array ($rec_ids[$i],$Picked))

- The port number of the URL in the php should be the same as the port number you are using for FM:

"http://localhost:1154/FMPro" 1154 is the port number I use.

- The line: require ("index.html") is displaying the page index.html. Instead, you could use:

echo $result

This will display the last Results.htm (or error.htm) page.

Hope this helps. All the best.

Garry

Posted

Thanks for the analysis, Garry. I figured there were errors!

In your original code, there was a field that was shown once without an s, then with an s, and I thought maybe the s indicated something in the code. I now realize that was Rec_id stuff!

I had also set Web Companion to use port 1154, to match your code. At the time (as you can see by my postings), I wasn't sure what port numbers were fair game.

I may still use this when we begin phase 2.

Thanks,

Ken

P.S. I tried to set this up again for my previous message, in order to show you the errors, but it wouldn't work. Is there an action I must do to get Apache running, and running with php?

Posted

Apache, on OS X, is your "Personal Web Sharing". Just have that "Started" from the "Sharing" preferences panel. PHP will not work unless Apache is running.

You can test PHP with the:

<?php

echo phpinfo();

?>

script as a file in the "Documents" folder (e.g. info.php).

All the best.

Garry

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