Genx Posted September 5, 2005 Posted September 5, 2005 Right, im sure this isnt that complex (but i can be a tad daft sometimes), i have 5 fields, single checkboxes with a value list set to each with the only option being "yes" within the checkbox (i know you can have one field with 5 options ive just being having trouble with the if statements). If certain checkboxes are selected i need a calculated result to be entered into another field. I.e. if field one is checked, add in text specific to that field. If field two is set to yes add more text to the previous text entered as a result of checkbox one being set to yes and so on. So i guess my final question is how would i setup a script to check which of the five checkboxes are checked (lets call the fields a - e) and insert text specific to whether or not those fields are set to "yes". I assume this has something to do with loops but i am yet to understand it. Help would be great, cheers in advance genx
aaa Posted September 5, 2005 Posted September 5, 2005 Why dont want have calculation field as: Text=Case(Field1="Yes","Field1_Checked","")& Case(Field2="Yes"," Field2_Checked","")& Case(Field3="Yes"," Field3_Checked","")& Case(Field4="Yes"," Field4_Checked","")& Case(Field5="Yes"," Field5_Checked","")
Genx Posted September 5, 2005 Author Posted September 5, 2005 well, i didnt know what the case function was for, cheers mate
Søren Dyhr Posted September 5, 2005 Posted September 5, 2005 Other options exists though, if you instead make the valuelist {1,2,4,8,16} instead and draw the single field in a way that hides these numbers, fiddling with custom linespacing makes sense as well. This makes this posible: Choose ( Evaluate ( Substitute ( CheckboxField ; "¶" ; " + " ) ) ; result0 {; result1 ; result2...} ) I would expect it to be slightly faster than Case'ing, and if searches are likely does it make sence to have just one indexed instead of five. --sd
comment Posted September 5, 2005 Posted September 5, 2005 Aren't you forgetting this is a checkbox field? A single field, with a list of 5 values, has 32 (2^5) possible states. Are you going to write out all 32 possible results for the Choose() function?
Søren Dyhr Posted September 5, 2005 Posted September 5, 2005 Aren't you forgetting this is a checkbox field? No I'm not ...it just occured to me that if you structure this way are you forced to think of all posibilities in a organized manner. Not that it's needed in this case, but... --sd
comment Posted September 5, 2005 Posted September 5, 2005 I have nothing against thinking. I was objecting to excessive typing. Here's how I would do this. (Seems upload is broken now - I'll try later)
Søren Dyhr Posted September 5, 2005 Posted September 5, 2005 Yes, hiccups occure ...eventhough I was among the jaw-droppers at devcon, when the topic was PHP ...might this be a flaw in the machinery serving or...: --sd
comment Posted September 5, 2005 Posted September 5, 2005 OK, let's try it now. CheckboxToText.fp7.zip
Genx Posted September 6, 2005 Author Posted September 6, 2005 cheers guys, comment your way ended up workin best. For future reference where do you get the § symbol and what abouts does it mean? Cheers
comment Posted September 6, 2005 Posted September 6, 2005 The actual character used is not important. I happen to have a non-standard keyboard with easy access to this character, but you can use any character that is not going to be used in the text. It has no meaning - it merely tags the last ¶, so that you don't end up with a trailing " and ".
Recommended Posts
This topic is 7020 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 accountSign in
Already have an account? Sign in here.
Sign In Now