On Mar 27, 2008, at 3:43 AM, Derek Hohls wrote:
Working with Cocoon 2.1.8

I am trying to create a simple event that copies the value entered in one
field, into another.

The form definition looks like:

<fd:field id="SiteCode" required="true">
 <fd:label>Site Code</fd:label>
 <fd:datatype base="string"/>
 <fd:on-value-changed>
   <javascript>

Should be <fd:javascript>.


java.lang.System.err.println("Site Code changed from " + event.oldValue + " to " + event.newValue);
     var value = event.source.value;
     var typewidget = event.source.lookupWidget("../SampleCode");
     typewidget.setValue(value);
   </javascript>
 </fd:on-value-changed>
</fd:field>

<fd:field id="SampleCode" >
 <fd:label>Sample Code</fd:label>
 <fd:datatype base="string"/>
</fd:field>

ie. the intent is that when SiteCode is changed, this value
becomes the default for the SampleCode.

The above does not work.

I am not sure where/how the system adds in this Javascript;
the source code for the output web page does not look any
different from before, so I am sure I am missing something
obvious.

There should be onchange="" javascript event attached to the "SiteCode" field in the generated html. Like in these samples:

  
http://cocoon.zones.apache.org/demos/21branch/samples/blocks/forms/countryselector
  http://cocoon.zones.apache.org/demos/21branch/samples/blocks/forms/carselector

It is added by the forms-field-styling.xsl stylesheet when widget has 'listening' attribute, which is set if there are any listeners attached.

Vadim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to