December 12, 200520 yr Hi my specify calculation is something like this.. if (a=0; b =1) else if (a=1; b =0) else ("") but i can't get it working.. can someone corrects me.. Thanks a lot.. Kelvin
December 12, 200520 yr Hi Kelvin, You haven't really explained much. Which field are you setting? B? Script would be use Insert Calculated Result[] or Set Field[] but I don't know which field we're setting. Set Field [ B ; not A ] But there would be no Else (or blank result if A is empty) because boolean translate 0 and blank exactly the same way. And that last Else ... do you mean that, if A is empty you want B to be empty? Aren't empty and 0 the same? Can you provide more information? I doubt you need a script here. If these two fields are within the same table, an auto-enter (Replace) calculation will take care of it for you - no script necessary. Try this as auto-enter (Replace) calculation on your B field. Be sure to uncheck in the calc box below 'Do not evaluate if all fields referenced are empty': If ( not IsEmpty ( A ) ; not A ) LaRetta
December 12, 200520 yr How about: If [ Your_TO::a = 0 ] Set Field [ Your_TO:: b; 1 ] Else If [ Your_TO::a = 1 ] Set Field [ Your_TO:: ; 0 ] Else Set Field [ Your_TO:: ; "" ] End If Lee
December 12, 200520 yr Author Hi LaRetta oh actually it is suppose to be a checkbox, but checkbox not supported in iwp so i changed it to ask user to enter 1 or 0. e.g. airticket: []Bookingrequired []Booking not required therefore when user enter 1 in either box, the other box will generate 0 in it and vice versa. Kelvin
December 12, 200520 yr I should add here that, for this to work, you will need to stop Users from accessing field B as free-text. It should be validated as: B = 1 or not B If you don't want them to change the field anyway, make it an indexed calculation instead. In this way, you won't have to protect the field from modification because you can't modify a calc. And you won't have to script it - it'll just consistently produce the correct result. Then all you will need to validate is field A. But then again ... I don't know if I'm even answering the right question. When you said you had a simple calculation I hope you realize that doesn't mean your QUESTION has to be quick (see disclaimer below). In fact, the more you share to begin with, the faster we can help you. [color:gray] Disclaimer: I am NOT a good model on how long a post should be. I tend to say too much, simply because I wish postees would say more. If I don't know enough about a situation then I start to feel like a call-in-for-advice talk show where they answer people's important questions without any proper background or direction. A dart board could do as well. LaRetta
December 12, 200520 yr I do not know IWP. You should be able to 1) Use radio buttons instead (that's their purpose) or 2) script it using a simple Set Field[] toggle as I indicated.
December 12, 200520 yr If [ Your_TO::a = 0 ] Set Field [ Your_TO:: b; 1 ] Else If [ Your_TO::a = 1 ] Set Field [ Your_TO:: ; 0 ] Else Set Field [ Your_TO:: ; "" ] End If That's exactly what my last calc says, Lee. But I guess you could list it out if you wish. This one line just says your script a bit different: Set Field [ B ; If ( not IsEmpty ( A ) ; not A ) ] But I still think a simple radio is the best. Just click the radio and it'll toggle for you. What happens if they enter a 6? Or a G? Actually, you want A to be yes (1) if ANYTHING is entered, right? And field B to go empty? This is possible with Auto-Enter but I'm feeling a bit blind because I don't know what's possible in IWP. L Edited December 12, 200520 yr by Guest
December 12, 200520 yr Author Hi LaRetta & Lee Really thanks for all the help and advices. I remembered wrongly, i thought that checkbox and radio buttons are not supported in iwp. I re-read my guide book again, it supports them but just that it don't maintain their columnar alignment. Therefore i decided just use the checkbox buttons as like what LaRetta said what if they enter other stuffs and not my 1 & 0. But when user choose 'A', can 'B' be greyed and if user choose 'B','A' be greyed which means it won't allows 2 fields to be checked. I am using 2 fields, field 'required' have 1 checkbox, field 'notrequired' have the other checkbox. Thanks a lot yeah for the fast response~ Kelvin
December 12, 200520 yr Hi Kelvin, The purpose of value lists is to provide more than one method of selection for a SINGLE field. If a field is clicked 'Required' then it's not required. You don't need two fields. It is an on/off, true/false, yes/no, empty/not empty thing. If Required is empty - it's not required! This is why a radio button is perfect. When User clicks Required, the ONE field will fill with your Value List value (a 1 or required)! You can attach script to both buttons and make it more complex for yourself, but I just want to be sure you understand how simple this really should be. Truly, all you have to do is use ONE field (Required) and it'll do it all naturally. Well this is how I suggest you approach it, any way, but you would use a checkbox. If you STILL want two fields and a script then okay, here's one possible way (see attached). Be sure to turn off entry into checkbox or radio field (whichever you choose). I gave you both examples side-by-side. The yellow fields are just to show the actual data in the field(s). You will need TWO scripts (I believe) because you are addressing two separate fields independently using Set Field[] instead of letting the Value List simply set one field. Right below the example, I've take the liberty of showing you how easy it could be if you use only one field and let FM do what it does best. LaRetta RadioCheckbox.zip
Create an account or sign in to comment