Hi:
I finally found a workaround to implement calculated widgets with
client-side JS (CSJS). To enhance the current support for CSJS I think we
need to define an id attribute for <wd:output>.
If we have an <wd:field> in the definition file:
<wd:field id="amount">
<wd:label>Amount</wd:label>
<wd:help>The Amount</wd:help>
<wd:datatype base="decimal"/>
<wd:validation><wd:range min="0"/></wd:validation>
</wd:field>
and in the template we wrote:
<wt:widget id="amount">
<wi:styling size="10" onchange="calculateTotal(this);"/>
</wt:widget>
The generated HTML snipet is:
<input title="" value="100" id="amount" name="amount" size="10"
OnChange="calculateTotal(this);">
<span class="woody-field-required"> * </span>
<div style="visibility:hidden; position:absolute;top:120px;right:0;"
id="helpN10290" class="woody-help">Total de Costo</div>
<script type="text/javascript">
var helpWinN10290 = woody_createPopupWindow('helpN10290');
</script>
<a onclick="helpWinN10290.showPopup('N10290');return false;"
href="#" id="N10290"><img src="images/help.gif" border="0"></a>
The id="amount" attribute is useful when we need to locate an object using
DOM in CSJS.
But, this attribute does not exist when we use a <wd:output> in
definition. :-(
I think we would generate at least a <span id="theOutputTagId"> for
<wd:output>. Tha way using CSJS we can easily find the <wd:output> we want
to change using CSJS.
WDYT?
Best Regards,
Antonio Gallardo