Jump to content

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

Recommended Posts

Posted

Does anyone know of a way to hide a button if a text field is empty, without using 2 different layouts?

Many thanks

Eddy.

Posted

You'll want to do more than hide the button -- you'll probably want to disable it too.

Disabling is easy -- just start the script with:

If(IsEmpty(FieldName))

Exit Script

"Hiding" the button involves a global container field and a calc field that returns a container. Put a graphic in the global field that matches the background. The calc field returns the contents of the global field if the field is empty.

Of course, that solution could be a problem in a multi-user environment.

Posted

Make the button a calculation (container). You will need to store the button in a global container and then have a calculation as follows:

If(IsEmpty(MyTextField) = 0, "MyStoredGraphic", "")

The script applied to your button will still be there. The script should be designed to not do anything if "MyTextField" is empty (using the same principles that the container calculation was created with)

If you want the button functionality to completely disappear you would need to create a relationship that displays the button (and its script) in a one-line portal if there is text in your text field.

Pete

Posted

Hello EddyB,

I suggest that you click the following link:

http://www.filemakerpros.com/Visible.zip

...which leads to a free download demo file from John Mark Osbourne's DatabasePros web site.

The file is one which shows a rather neat technique which has been widely promulgated by JMO, for doing exactly what you have in mind. One useful aspect is that the same effect which causea the button to disappear will also diable it. wink.gif

Posted

Thanks all - I will have a look at all your suggestions and I'm sure you have given me my answer!

Many Thanks

EddyB

Posted

Ok, going with the portal idea - had a look at the DatabasePros example which uses portals to hide text fields and buttons dependant on other firelds, and it's very effective so thanks all- just what I needed!

Ed.

Posted

Thanks for spending the time on it Pete, I have downloaded your example as well as the databasepros one. I'm sure with the 2 examples now I have my answer, just got to work on it now - you know I've been developing on FMPro for about 3/4 years and never used a portal! - looks like I've been missing out!!

Many thanks

Ed.

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