We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

Question

I have a topic which includes a form. On this topic I would like to use %IF statement, in which results will depend on formfield value specified in condition. Formfield type: select, possible values: A, B. If formfield=A then="X" else="Y".

Is it possible to use formfield in %IF% ?

%IF{"$formfield(formfieldName)='formfieldValue'" then="THEN" else="ELSE"}%

Environment

TWiki version: TWikiRelease04x01x01
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Debian GNU/Linux
Web server: Apache/2.0.54
Perl version: Perl/v5.8.4
Client OS: Microsoft Windows XP (Service Pack 2)
Web Browser: FireFox? 2.0.0.3
Categories: Forms

-- AnnaPapierz - 08 May 2007

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

Reading the IfStatements docs, it does not look like IF supports form fields. Possibly combine with %FORMFIELD{}%

-- PeterThoeny - 09 May 2007

Peter is right. Using FORMFIELD:

   * Test on !AnsweredQuestions: %IF{"$'FORMFIELD{SupportStatus}'='AnsweredQuestions'" then="This question has been answered" else="not (so asked)"}%
   * Test on !AskedQuestions: %IF{"$'FORMFIELD{SupportStatus}'='AskedQuestions'" then="This question has not been answered" else="not (so answered)"}%

Results in:

  • Test on AnsweredQuestions: This question has been answered
  • Test on AskedQuestions: not (so answered)

-- ArthurClemens - 09 May 2007

Thanks you all for a tip, I have already checked and this works.

-- AnnaPapierz - 09 May 2007

Does anyone know if this works with % SEARCH %? So, if the form is not on the topic, but I want to display conditional text in a search table (that is based on a form field in the topics being searched), is there a way to use the same feature?

-- LaurenSommer - 24 Oct 2007

I used the SpreadSheetPlugin for that purpose. I tried to check whether a formfield (containing multiple values) contains the String "WarnHinweise". Here is the code:

$percntCALC{\"$IF(  $SEARCH(WarnHinweise, $LISTJOIN($expand(SubjectCategory)) )>0, !! Warnhinweis !! )\"}$percnt
Don´t forget to escape the CALC statement.

-- PeterSykora - 31 Oct 2007

 
Change status to:
Topic revision: r8 - 31 Oct 2007 - 18:59:07 - PeterThoeny
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback