[phorm] [Phorm:] Re: Parsing an array?

  • From: webbbs@xxxxxxxxx
  • To: support@xxxxxxxxx
  • Date: 5 Aug 2004 16:37:04 -0000

The following new message has been posted on Phorm Support Forum at 
<http://www.phorm.com/support/>. 

*************************************************************************** 

  MESSAGE:  (#4233) Re: Parsing an array? 
            <http://www.phorm.com/support/?rev=4233> 
  AUTHOR:   Bob Brody 
  DATE:     August 5, 2004 at 12:36 p.m. EST 

  Reply To: (#4231) Parsing an array? 
  Author:   Bob Brody 
  Date:     August 5, 2004 at 8:56 a.m. EST 

I think I'm getting closer. Actually I think this can be done in the rules 
file. This has worked (somewhat): 

RULE: 12 
CRIT: REQ 
FFLD: daquestion 
COND: $daquestion =="" && $colors =="red" 
LEVL: 1 
MESG: <li>Text........ 
### 

That worked. If the radio buttons yes/no were left unchecked for daquestion 
and I checked off red in the colors group, the message came up. 

However, what if the person checks more than just red in the colors group. 
Say, he checks off red, blue, green. The $colors variable now contains "red, 
blue and green" 

Thus, $colors == "red" fails because $colors equals more than just red. 

So the question is, how can I have it do this: 

RULE: 12 
CRIT: REQ 
FFLD: daquestion 
COND: $daquestion =="" && $colors [CONTAINS] "red" 
LEVL: 1 
MESG: <li>Text........ 
### 

I.e., as long as red is within $colors, regardless what else might be in 
there, then the condition is met. Ya think? Seems sensible to me, but alas I 
don't know how to code that string. Anybody? 

Thanks. 
Bob 

> I have a situation where I have, say, five check boxes 
> in a group. It's an array and each box is, say, a 
> color. 

> <INPUT TYPE=CHECKBOX NAME="colors[]" 
> value="red"> 
> <INPUT TYPE=CHECKBOX NAME="colors[]" 
> value="green"> 
> <INPUT TYPE=CHECKBOX NAME="colors[]" 
> value="blue"> 
> <INPUT TYPE=CHECKBOX NAME="colors[]" 
> value="pink"> 
> <INPUT TYPE=CHECKBOX NAME="colors[]" 
> value="white"> 

> I then have another group, say, fabric. 

> <INPUT TYPE=CHECKBOX NAME="fabric[]" 
> value="silk"> 
> <INPUT TYPE=CHECKBOX NAME="fabric[]" 
> value="cotton"> 
> <INPUT TYPE=CHECKBOX NAME="fabric[]" 
> value="rayon"> 
> <INPUT TYPE=CHECKBOX NAME="fabric[]" 
> value="wool"> 
> <INPUT TYPE=CHECKBOX NAME="fabric[]" 
> value="burlap"> 

> The user has to choose at least one choice from at 
> least one group (i.e., they don't have to choose 
> something from colors AND from fabric but they do have 
> to choose at least something from colors OR fabric. 

> Okay, that works. Now the rub is, there is a yes/no 
> radio buttons question later into the form that has 
> relevance to which if any color they chose, 
> specifically, red. 

> Thus, if they chose red, then I want to make that 
> subsequent yes/no question (let's call its value 
> "daquestion") a required field, but only if 
> they chose red. Otherwise daquestion need not be 
> required. 

> So in non programming lingo, something such as: 

> If colors = true AND red = true, then daquestion is 
> required (you must answer either yes or no). 
> Otherwise, you don't have to answer daquestion. 

> What I haven't figured out is how do I find out if 
> "red" has been checked off in 
> "colors" assuming anything at all has been 
> checked off in "colors". No problem testing 
> to see that colors has been checked: 

> if colors != "" 

> but can I then also continue to find out what colors 
> does equal if it does not equal nothing? 

> if colors != "" 
> and colors == red 
> then daquestion becomes required 

> Is something like that possible? 

> Bob 

*************************************************************************** 

This is an automatically-generated notice.  If you'd like to be removed from 
the mailing list, please visit Phorm Support Forum at 
<http://www.phorm.com/support/>, or send your request to webbbs@xxxxxxxxxx  If 
you wish to respond to this message, please post your response directly to the 
board.  Thank you! 
-------------------------------------------------
You are receiving this message because you are subscribed to the Phorm mailing 
list. To send messages to the mailing list, simply send email to 
phorm@xxxxxxxxxxxxx from the address you have subscribed. You may unsubscribe 
from the list by sending email to phorm-request@xxxxxxxxxxxxx with 
'unsubscribe' in the SUBJECT field.

Other related posts: