cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lionel Crine <cr...@4dconcept.fr>
Subject Re: cforms: mutliple booleanfields validation
Date Fri, 13 May 2005 10:12:55 GMT
Hi,

I have written some javascript to set dynamically some checkbox.

Here it is :

Lionel

------------------

<fd:booleanfield id="unverif">
      <fd:on-value-changed>
        <javascript>
         var value = event.source.value;
           var firstverWidget = event.source.lookupWidget("../firstver");
           var secverWidget = event.source.lookupWidget("../secver");
           if (value == "true") {
             firstverWidget.setValue(false);
             secverWidget.setValue(false);
           }
          </javascript>
      </fd:on-value-changed>
    </fd:booleanfield>
    <fd:booleanfield id="firstver">
      <fd:on-value-changed>
        <javascript>
          var value = event.source.value;
            var unverifWidget = event.source.lookupWidget("../unverif");
          var secverWidget = event.source.lookupWidget("../secver");
          var secverWidgetValue= secverWidget.value;
            if (value == "true") {
             unverifWidget.setValue(false);
              if (secverWidgetValue == "false") {
               secverWidget.setValue(false);
                }
        }
        if (value == "false") {
         secverWidget.setValue(false);
        }
<!--                     // Always set the type value to null. Note that 
it will also fire an event on the "type"
            // widget if it already had a value.-->
<!--            unverifWidget.setValue(null);
          firstverWidget.setValue(null);
            firstvertypeWidget.setValue(null);
            secverWidget.setValue(null);
             secvertypeWidget.setValue(null);-->
        </javascript>
      </fd:on-value-changed>
    </fd:booleanfield>
    <fd:booleanfield id="secver">
      <fd:on-value-changed>
        <javascript>
          var value = event.source.value;
            var unverifWidget = event.source.lookupWidget("../unverif");
          var firstverWidget = event.source.lookupWidget("../firstver");
          var firstverWidgetValue = firstverWidget.value;
            if (value == "true") {
             unverifWidget.setValue(false);
             firstverWidget.setValue(true);
        }
        if (value == "false") {
         if (firstverWidgetValue == "true"){
       
         }
        }
          <!--            // Always set the type value to null. Note 
that it will also fire an event on the "type"
            // widget if it already had a value.
            typewidget.setValue(null);-->
        </javascript>
      </fd:on-value-changed>
    </fd:booleanfield>

---------------------

Peter Kröpfl wrote:

>Hi,
>
>I have mutliple booleanfield widgets and want to make sure, that at least one of
>them is checked. How would I do that?
>
>I allready searched this newsgroup for similar questions, but i could not find
>any. Looking at the samples I figured I could use <fd:javascript> and write my
>own validation function in flow. However, I don't know how to access the widgets
>in this function.
>
>I hope somebody has allready done something like that and could help me.
>
>Thanks, peter
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>

-- 
Lionel CRINE
Ingénieur Systèmes documentaires
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.46.06.90


Mime
View raw message