Ben Anderson wrote:
Hi, I have one text field which, once changed, will populate 2 drop down lists. However, the 2nd drop down is dependent on the 1st drop down.
So, I have this in my text field's definition
<fd:on-value-changed>
<javascript>
...
// this populates the 1st drop down
raIdWidget.setSelectionList("cocoon:/selection-lists/raIds?raSearch=" + value)
// I'd like to get the first value out of this select list. Is this possible?
// I tried the following line, but it doesn't work... it's still the old value.
// var raId = raIdWidget.value
// Because now I'd like to trigger an event
raIdWidget.broadcastEvent(
new Packages.org.apache.cocoon.forms.event.ValueChangedEvent(
raIdWidget,
raIdOldValue,
raId));
...
broadcastEvent is really an internal method that should be used only by CForms itself, and you should not use it in your application code.
and then in the javascript for the value changed event of the 1st drop-down, I populate the 2nd drop down.
This seems to all fit together except for the above mentioned gap. Is
there a way to get a value out of the selection list, even though it
isn't explicitly set?
You cannot get a value out of the selection list, except by fetching a value from the SAX stream it produces. However, you can explicitely set the value of the widget whose selection list has changed.
What's usually done in such cases is to set the value of the widget whose list has changed to null. Have a look at the carselector in the forms samples that examplifies this.
Sylvain
-- Sylvain Wallez Anyware Technologies http://apache.org/~sylvain http://anyware-tech.com Apache Software Foundation Member Research & Technology Director
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
