Jump to content

FMP-If/Else Question


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

Recommended Posts

Hello All.....

I'm trying to get an FMP-If/FMP-Else statement to work. From the FileMaker site, I found this:

[FMP-If: (Field:name.Eq.david).or.(Field:name.Eq.dave)]

Welcome David!

[FMP-ElseIf: Field:name.Eq.eric]

Hi Eric!

[FMP-Else]

Hi Stranger!

[/FMP-If]

Even though I've tried to follow this code for my solution it doesn't work. I would also like to add an .or. statement to the Else line (if that's possible). This is my code so far. What it should be saying is if the event isn't full or you are allowed to register, a button appears to proceed to registration. If the event is full or if you are NOT allowed to register, a statement appears saying that the class is full or no registration allowed.

[color:"blue"]

[FMP-If: (FMP-Field:Event_Full.neq.X).or.(FMP-Field:Event_No_Register.eq.Registration_Allowed)]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-Else: (FMP-Field:Event_Full.eq.X).or.(FMP-Field:Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">This class is either full or no registrations are allowed at this time.</FONT></CENTER></P>

[/FMP-If]

Any suggestions? Thanks in advance. Donna

Link to comment
Share on other sites

Try this:

[FMP-If: (Field:Event_Full.neq.X).or.(Field:Event_No_Register.eq.Registration_Allowed)]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-ElseIf: (Field:Event_Full.eq.X).or.(Field:Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">This class is either full or no registrations are allowed at this time.</FONT></CENTER></P>

[/FMP-If]

Good Luck.

Garry

Link to comment
Share on other sites

Hi Garry!

From what I could tell you were just suggesting that I change the FMP-Else to a FMP-ElseIf. I did the change but it's no better.

It acknowledges the first part of the statement.....

[FMP-ElseIf: (Field:Event_Full.eq.X)......but it doesn't acknowledge the second part at all.

I thought it might be how I had the field set up. At first, I had checkboxes for the field Event_No_Register. The choices being Registration_Allowed or No_Registration_Allowed. I changed it to a drop down list but that didn't help. I also verified that this field is on the layout that I'm using. No problem there.

Any other suggestions????? Donna

Link to comment
Share on other sites

It was also changing this: (FMP-Field:Event_Full.neq.X) to this (Field:Event_Full.neq.X)

It maybe a limitation of CDML. If so, you can try nesting the IF statements, for example:

[FMP-If: (Field:Event_Full.neq.X).or.(Field:Event_No_Register.eq.Registration_Allowed)]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-Else]

[FMP-If: (Field:Event_Full.eq.X).or.(Field:Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">This class is either full or no registrations are allowed at this time.</FONT></CENTER></P>

[/FMP-If]

[/FMP-If]

Good Luck.

Garry

Link to comment
Share on other sites

Hi Garry.....

I gave your suggestion a try and parts of it worked and parts of it didn't.

After changing this code around for over 5 hours, this is where it ended up. It's better but not exactly what I was looking for:

[color:"blue"]

[FMP-If: Field:Event_Full.neq.X]

[FMP-If: Field:Event_No_Register.eq.Registration_Allowed]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-Else]

[FMP-If: (Field:Event_Full.eq.X).or.(Field:Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">This class is either full or no registrations are allowed at this time.</FONT></CENTER></P>

[/FMP-If]

[/FMP-If]

[/FMP-If]

The first two IF statements do what they are suppose to do. If it's okay to register and the class isn't full, I get a "login" button to proceed with registration.

However, the last IF statement only does what I partially want it to do. It's really odd.

If the class is full, I get nothing. No statement regarding the class being full but I also don't get a login button.

If registration isn't allowed. Then I get the statement "this class is either full....."

So, it is evaluating the IF statements, it's just not putting the "this class is either full....." statement on the screen when the class is full.

I started with your suggestion of one IF statement at the beginning but that didn't work. I then broke up that statement into two separate ones and that works. I have tried the ElseIf command. I have tried a combination of the Else and Else-If commands (like the example from FM). I broke the second IF statement up like the first, but that didn't work either.

The code above works the best, so I probably will move on since this isn't the end of the world, but I just don't understand why it won't put that statement there when the class is full.

If anyone has any other suggestions, I'd be happy to try them....... thanks! Donna

Link to comment
Share on other sites

Re: [FMP-If: (FMP-Field:Event_Full.neq.X).or.(FMP-Field:Event_No_Register.eq.Registration_Allowed)] (first post)

I do not understand why you are involving two fields. It seems like it could be a conflicting circularity (without knowing more). If an event is full, registration is not to be allowed or if an event is no_register, registration is not to be allowed. Is the second (no-register) field one which is to prohibit registration even if the event is not full?

Why not:

[FMP-If: Field:Event_Full.neq.X]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-Else]

<P><CENTER><FONT COLOR="#008080">This class is either full or no registrations are allowed at this time.</FONT></CENTER></P>

[/FMP-If]

Link to comment
Share on other sites

The second field is to give us the option of whether or not we want users to be able to register for a class via the web.

Why would we do this......perhaps the class has been cancelled due to lack of registration, so three days before we make that decision and now I don't want anyone to register. Perhaps we have spots available, but because of the number of handouts a workshop requires, we have to stop registration three days before an event is held, so we have enough material created. There's all kinds of reasons.

I can get this to work just fine with the only issue being whether or not the class is full. It's when I started trying to add another element into the mix that I had some problems. My last posted solution works for the most part. I just can't get the statement to come out for the class being full.

Thanks! Donna

Link to comment
Share on other sites

Just a couple of minor changes, but I tried this and it worked for me (FMPro 5.0.v3):

[FMP-If: Field: Event_Full.neq.1.or.(Field:Event_No_Register.neq.No_Registration_Allowed)]

<B>To register for this event, a form would be here with a button To Register</b>

[FMP-Else]

[FMP-If: Field: Event_Full.eq.1.or.(field: Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">This class is either full or no registrations are allowed at this time.</FONT></CENTER></P>

[/FMP-If]

[/FMP-If]

HTH

Link to comment
Share on other sites

Hi Unable.......

I tried your changes today, but now when a class is "full" it gives the login button (which it's not suppose to do).

Here's my code......

[FMP-If: Field: Event_Full.neq.1.or.(Field: Event_No_Register.neq.No_Registration_Allowed)]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-Else]

[FMP-If: Field: Event_Full.eq.1.or.(Field: Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">Registrations are not allowed at this time.</FONT></CENTER></P>

[/FMP-If]

[/FMP-If]

I'm on FM 6.0 v4. Thanks for the effort but I'll have to go back to what I had before. At least that code didn't give them a login button when the class was full. This is so frustrating! Donna

Link to comment
Share on other sites

Perhaps it has to do with your form action, possibly where it ends/

Perhaps if you posted the pertinent code between

<form method=...

</form>

in relation to the [FMP-If] ... [/FMP-if],

I might gain a better understanding.

In my personal test I had one entire form action between the [FMP-If] and the [FMP-Else].

Link to comment
Share on other sites

Unable is -- as always smile.gif -- right.

Use [FMP-If]

your complete working HTML code not just part

<form>

</form>

[FMP-Else]

your another complete working HTML code

<form>

</form>

[/FMP-if]

That way the code is slightly larger (not a big deal with current hardware) but always fully readable and not open to mistakes.

Link to comment
Share on other sites

Here you go.....this is most of the code starting with the FORM. Now that I read this as a whole again......my form ends after the FMP-IF statement......maybe it is the location of the Form.

Thanks for taking a look......

<FORM NAME="verify" ACTION="FMPro" METHOD="post">

<INPUT TYPE="hidden" NAME="-DB" VALUE="CE_Events">

<INPUT TYPE="hidden" NAME="-format" VALUE="login.htm">

<INPUT TYPE="hidden" NAME="-lay" VALUE="Online">

<INPUT TYPE="hidden" NAME="-Token.3" VALUE="[FMP-field: Event_ID]">

<INPUT TYPE="hidden" NAME="-Token.4" VALUE="[FMP-field: Event_Name]">

<INPUT TYPE="hidden" NAME="-Token.7" VALUE="[FMP-field: Event_Full]">

<TABLE BORDER=0 WIDTH=700 CELLSPACING=1 CELLPADDING=1>

<TR>

<TD ROWSPAN=4 ALIGN="left" WIDTH=100><IMG ALT="bee" SRC="grad_bee.jpg"></TD>

</TR>

</TABLE>

<HR NOSHADOW color="teal">

<BR>

<CENTER><B>EVENT SUMMARY</B></CENTER><BR><BR>

<CENTER>Name: <FONT COLOR="#008080">[FMP-field: Event_Name, format]</FONT></CENTER><BR>

</CENTER>

<TABLE WIDTH="70%" ALIGN="center" BORDER="3">

<TR>

<TD ALIGN="center" WIDTH="40%"><B>Registration Information</B>:P</TD>

<TD ALIGN="center" WIDTH="50%"><B>Event Information</B>:</TD>

</TR>

<TR></TR>

<TR>

<TD ALIGN="left" WIDTH="40%">Date: <FONT COLOR="#008080">[FMP-field: Event_Date, format]</FONT></TD>

<TD ALIGN="left" WIDTH="50%">Event ID: <FONT COLOR="#008080">[FMP-field: Event_ID, format]</FONT></TD>

</TR>

<TR>

<TD ALIGN="left" WIDTH="40%">Time: <FONT COLOR="#008080">[FMP-field: Event_Start, format] - [FMP-field: Event_End, format]</FONT></TD>

<TD ALIGN="left" WIDTH="50%">Type: <FONT COLOR="#008080">[FMP-field: Event_Type]</FONT></TD>

</TR>

<TR>

<TD ALIGN="left" WIDTH="40%">Registration Limit: <FONT COLOR="#008080">[FMP-field: Event_Registration_Limit, format]</FONT></TD>

<TD ALIGN="left" WIDTH="50%">Location: <FONT COLOR="#008080">[FMP-field: Event_Location, format]</FONT></TD>

</TR>

<TR>

<TD ALIGN="left" WIDTH="40%">Current Registered Participants: <FONT COLOR="#008080">[FMP-field: Registrants_without_LTLS, format]</FONT></TD>

<TD ALIGN="left" WIDTH="50%">Fee: <FONT COLOR="#008080">[FMP-field: Event_Fee_Amt, format]</FONT></TD>

</TR>

<TR>

<TD ALIGN="left" WIDTH="40%">Contact Hours: <FONT COLOR="#008080">[FMP-field: Event_Contact_Hours, format]</FONT></TD>

<TD ALIGN="left" WIDTH="50%">Topic: <FONT COLOR="#008080">[FMP-field: Event_Topic, format]</FONT></TD>

</TR>

<TR>

<TD ALIGN="left" WIDTH="40%">Credits: <FONT COLOR="#008080">[FMP-field: No._of_Credits, format] &nbsp; [FMP-field: Credits]</FONT></TD>

<TD ALIGN="left" WIDTH="50%">Category: <FONT COLOR="#008080">[FMP-field: Category_of_Class, format]</FONT></TD>

</TR>

<TD ALIGN="left" WIDTH="40%">Full: <FONT COLOR="#008080">[FMP-field: Event_Full, format]</TD>

<TD ALIGN="left" WIDTH="50%">Flyer: &nbsp; <A HREF="[FMP-field: Event_Flyer_URL]">Click Here</A></FONT></TD>

</TR>

</TABLE>

<BR><BR>

[FMP-If: Field:Event_Full.neq.X]

[FMP-If: Field:Event_No_Register.eq.Registration_Allowed]

<CENTER><B>To register for this event,

<INPUT TYPE="hidden" NAME="-view">

<INPUT TYPE="submit" NAME="-View" Value="Login to Register">

[FMP-Else]

[FMP-If: (Field:Event_Full.eq.X).or.(Field:Event_No_Register.eq.No_Registration_Allowed)]

<P><CENTER><FONT COLOR="#008080">Registrations are not allowed at this time.</FONT></CENTER></P>

[/FMP-If]

[/FMP-If]

[/FMP-If]

</FORM>

Donna

Link to comment
Share on other sites

Donna, yes, enclose the form between the [FMP-If] and the [FMP-Else].

1. Opening the form above the table is not necessary as it has no bearing on the table (as I read it), so it should follow the [FMP-If].

2. By closing the form where you have, the button must appear if the Else condtional is met. That is why the form should be closed prior to the else.

3. You should be able to combine the first two [FMP-If]'s into one .or. statement and then remove the third close. From the example I posted above, I suggested something like

[FMP-If: Field:Event_Full.neq.X.or.(Field:Event_No_Register.neq.No_Registration_Allowed)]

I assumed that the field Event_No_Reigster might contain "Registration_Allowed" or "No_Registration_Allowed" or might be left blank or might be given some other descriptive term. By checking that it not equal No_Registration_Allowed, as long as that condition is met registration is allowed and any other condition (whether a blank field, "Registration_Allowed" or something else) will not interfere with registration proceeding.

As long as the field will contain only "Registration_Allowed" or "No_Registration_Allowed", then your language will probably work if modified to read:

[FMP-If: Field:Event_Full.neq.X.or.(Field:Event_No_Register.eq.Registration_Allowed)]

Link to comment
Share on other sites

Hello to all.....

What I ended up doing was splitting the Full part of the equation off completely by itself. I put it at the top of the form in the first table (with FMP-IF and /FMP-IF surrounding it) and now everything works.

I think the answer is that the ELSE statements cannot use .or.

Thanks for all the help. This now works well enough for what I need it for.......Donna

Link to comment
Share on other sites

Unable.....

I tried the statement in your demo many, many times.....it didn't work. I'm on FM 6 v.4.

I also have to work with 20+ databases that have existed since 1995.....and I'm limited on what I can change, etc. There's just too much data and too many relationships.

if I could start from scratch it might be easier but I can't do that.

The solution that I posted works just great, I just didn't have the .or. on the Else part of the statement.

I've also realized that now that I have split the FULL statement off from the others that I can develop a wait-listing feature. I actually like it much better this way.

Maybe, someone more talented than I can figure it out for FM 6.

Thanks for all your help. Donna

Link to comment
Share on other sites

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