Hi, I
have an input field named ‘Sum Insured’ inside a repeat table which
accepts only numeric values. And outside the repeat table, I have an output
control named ‘total’ which calculates the sum of all Sum Insured
fields. For this I have added an xforms:bind for total as: <xforms:bind
id="totalsum" nodeset="instance('AssignRisk')/total"calculate="sum(instance('AssignRisk')//suminsured)"
></xforms:bind> The
problem is that when the number in the total field becomes too big, it will be
displayed in exponential form in the label(eg: 1.22E6). However, when you submit the form, the
instance will have the numeric value itself rather than exponential. I need to
display as numeric value in the label rather than exponential. Is there any
easy way to implement this? I got a javascript function which converts
exponential value to numeric; is there any way by which we can call this
javascript from within the calculate method passing the sum of all Sum Insured
fields. Or do I have to call this function on value changed event of output
control? Please
help me to implement this in an easy way Thanks
in advance Jency -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Jency,
I don't think you need JavaScript. When you display the value, you can use something like: <xforms:output ref="total" xxforms:format="if (. castable as xs:decimal) then format-number(xs:decimal(.),'###,###,###,##0.00') else ."/> In fact, if you use @ref on xforms:output (instead of @value), and if you specify a decimal type on the bind, this should happen automatically: <xforms:bind ... type="xs:decimal"/> -Erik On Mar 5, 2008, at 4:10 AM, Jency Thomas wrote: > Hi, > > I have an input field named ‘Sum Insured’ inside a repeat table > which accepts only numeric values. And outside the repeat table, I > have an output control named ‘total’ which calculates the sum of all > Sum Insured fields. For this I have added an xforms:bind for total as: > > <xforms:bind id="totalsum" nodeset="instance('AssignRisk')/ > total"calculate="sum(instance('AssignRisk')//suminsured)" ></ > xforms:bind> > > The problem is that when the number in the total field becomes too > big, it will be displayed in exponential form in the label(eg: > 1.22E6). However, when you submit the form, the instance will have > the numeric value itself rather than exponential. I need to display > as numeric value in the label rather than exponential. Is there any > easy way to implement this? I got a javascript function which > converts exponential value to numeric; is there any way by which we > can call this javascript from within the calculate method passing > the sum of all Sum Insured fields. Or do I have to call this > function on value changed event of output control? > > Please help me to implement this in an easy way > > Thanks in advance > Jency Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Thanks Erik for the solution. But when I tried to give the bind alone as, <xforms:bind nodeset="instance('AssignRisk')/total" type="xs:decimal" calculate="sum(instance('AssignRisk')//suminsured)"/> it didn't work. Also, it shows validation error when exponential symbol comes in the output field. So I removed the bind and gave xxforms:format as <xforms:output ref="total" xxforms:format="if (. castable as xs:decimal) then format-number(xs:decimal(.),'###,###,###,##0.00') else ."/> This too did not work. Since this bind already has a calculate attached to it, it seems it first calculates the sum and gets the value in exponential form; then it tries to apply the xxforms:format to it; and since it is not castable as xs:decimal, it displays the value as it is. So, finally I removed the "if - else" part from xxforms:format and it worked: <xforms:output ref="total" xxforms:format="format-number(.,'###,###,###,##0.00')"> Thanks Jency -----Original Message----- From: Erik Bruchez [mailto:[hidden email]] Sent: Wednesday, March 05, 2008 9:27 PM To: [hidden email] Subject: [ops-users] Re: exponential value displayed in output control Jency, I don't think you need JavaScript. When you display the value, you can use something like: <xforms:output ref="total" xxforms:format="if (. castable as xs:decimal) then format-number(xs:decimal(.),'###,###,###,##0.00') else ."/> In fact, if you use @ref on xforms:output (instead of @value), and if you specify a decimal type on the bind, this should happen automatically: <xforms:bind ... type="xs:decimal"/> -Erik On Mar 5, 2008, at 4:10 AM, Jency Thomas wrote: > Hi, > > I have an input field named 'Sum Insured' inside a repeat table > which accepts only numeric values. And outside the repeat table, I > have an output control named 'total' which calculates the sum of all > Sum Insured fields. For this I have added an xforms:bind for total as: > > <xforms:bind id="totalsum" nodeset="instance('AssignRisk')/ > total"calculate="sum(instance('AssignRisk')//suminsured)" ></ > xforms:bind> > > The problem is that when the number in the total field becomes too > big, it will be displayed in exponential form in the label(eg: > 1.22E6). However, when you submit the form, the instance will have > the numeric value itself rather than exponential. I need to display > as numeric value in the label rather than exponential. Is there any > easy way to implement this? I got a javascript function which > converts exponential value to numeric; is there any way by which we > can call this javascript from within the calculate method passing > the sum of all Sum Insured fields. Or do I have to call this > function on value changed event of output control? > > Please help me to implement this in an easy way > > Thanks in advance > Jency Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
In reply to this post by Erik Bruchez
It worked when I gave the type as xforms:float or xforms:double without xxforms:format. Thanks a lot Erik. I have some doubts regarding formatting: 1) Can we use xxforms:format for xforms:input control other than when it is bound to date type. Or is it possible to format only output control and date fields? I tried to give xxforms:format to xforms:input but it is not working. 2) Like format-number(), is there any way to format a string? Thanks Jency -----Original Message----- From: Erik Bruchez [mailto:[hidden email]] Sent: Wednesday, March 05, 2008 9:27 PM To: [hidden email] Subject: [ops-users] Re: exponential value displayed in output control Jency, I don't think you need JavaScript. When you display the value, you can use something like: <xforms:output ref="total" xxforms:format="if (. castable as xs:decimal) then format-number(xs:decimal(.),'###,###,###,##0.00') else ."/> In fact, if you use @ref on xforms:output (instead of @value), and if you specify a decimal type on the bind, this should happen automatically: <xforms:bind ... type="xs:decimal"/> -Erik On Mar 5, 2008, at 4:10 AM, Jency Thomas wrote: > Hi, > > I have an input field named 'Sum Insured' inside a repeat table > which accepts only numeric values. And outside the repeat table, I > have an output control named 'total' which calculates the sum of all > Sum Insured fields. For this I have added an xforms:bind for total as: > > <xforms:bind id="totalsum" nodeset="instance('AssignRisk')/ > total"calculate="sum(instance('AssignRisk')//suminsured)" ></ > xforms:bind> > > The problem is that when the number in the total field becomes too > big, it will be displayed in exponential form in the label(eg: > 1.22E6). However, when you submit the form, the instance will have > the numeric value itself rather than exponential. I need to display > as numeric value in the label rather than exponential. Is there any > easy way to implement this? I got a javascript function which > converts exponential value to numeric; is there any way by which we > can call this javascript from within the calculate method passing > the sum of all Sum Insured fields. Or do I have to call this > function on value changed event of output control? > > Please help me to implement this in an easy way > > Thanks in advance > Jency Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
> It worked when I gave the type as xforms:float or xforms:double
> without > xxforms:format. Thanks a lot Erik. Great. > I have some doubts regarding formatting: > > 1) Can we use xxforms:format for xforms:input control other than > when it is bound to date type. Or is it possible to format only output > control and date fields? I tried to give xxforms:format to > xforms:input > but it is not working. I think you answered your own question ;-) xxforms:format won't work to format input. > 2) Like format-number(), is there any way to format a string? I fear not, but what would such a function do? -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |