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 - 2007-10-31 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.