Expand my Community achievements bar.

Urgent Help

Avatar

Former Community Member
I need to resolve this bug in my form which is quite weird....

I have a legal form here with a couple of text boxes .. Now each of these text boxes have been coded in java script for some calculations(numerical)



The Issue with this form is when i insert the values and press enter the values invert to zero.... so when i do it again it does insert the values ... The weird thing about this ,it doesnt happen all the time...It works sometimes with out any problem but there are times when it just goes back to zero again...



Note that these text boxes are prepopulated by zero in the form
3 Replies

Avatar

Former Community Member
Aafreen,



Not sure if you resolve your issue, but if you have an example that you can share, and steps to reproduce. I can look at it.



David

www.ensemble.com

Avatar

Former Community Member
Basically there are two check boxes above the text boxes with the values "Buyer" for on and and 0 for off<br /><br /> there are 7 text boxes arranged one after the other....<br /> U can enter the values from the first,third and sixth text box...<br /> and the calculated amount will be displayed in rest of the boxes...<br /><br />Here's the Code for all the text boxes :<br /><br />*First text box:<field name="xPP" relevant="- "><br /> <ui><br /> <numericEdit><br /> </numericEdit><br /> </ui><br /> <value><br /> <float>0.00</float><br /> </value><br /> <format><br /> <picture>num(en){s'$'zzz,zzz,zzz,zzz,zz9.99}</picture><br /> </format><br /><event activity="exit"><br /> <script contentType="application/x-javascript">F.variables.math.math123();</script><br /> </event><br /> <traversal><br /> <traverse ref="xGUC[0]"/><br /> </traversal><br /> </field><br />*Second Text box named as xGUC,is same as above with out a java script function ...<br /><br />*Third Text boxx 'xValueC' is as same as the second one... <br /><br />*The fourth is text box 'xValuea_c' the is almost the same but with an additional calculation shown below:<br /> <calculate><br /> <script contentType="application/x-javascript">var m = xfa.form.F.xxPage2.xGUC.rawValue ;<br />var j = xfa.form.F.xxPage2.xValueC.rawValue ;<br />this.rawValue = m - j ;</script><br /> </calculate><br /><br />*The Fifth Text box'xValueB': has this additional java script and the rest is the same.<br /><calculate><br /> <script contentType="application/x-javascript">i = xfa.form.F.xxPage2.xValuea_c.rawValue;<br /><br />//divide by 500<br />i = i /500;<br /><br />//round up to the nearest whole dollar<br />i = Math.ceil(i);<br /><br />//multiply this by 2<br />i = i * 2;<br /><br />this.rawValue = i;</script><br /> </calculate><br /><br />*And the Sixth Text box 'xbhbh' is the as second and third <br /><br />*The Seventh text bo 'xResultsC' has this java script<br /><calculate><br /> <script contentType="application/x-javascript">a = xfa.form.F.xxPage2.xbhbh.rawValue;<br />b = xfa.form.F.xxPage2.xValueB.rawValue;<br /><br />this.rawValue = b- a;</script><br /> </calculate<br /><br /> Here is the java script functions it uses : <br /><br /></script><br /> <script name="AutoTab" contentType="application/x-javascript">function AutoTab(eventObject, nextFieldName)<br />{<br />}</script><br /> <script name="math" contentType="application/xjavascript">function math123()<br />{<br />//app.alert("Math");<br />var PP = 0;<br />var GUC = 0;<br />var state = 0;<br />var city = 0;<br /><br />//Get the base purchase price<br />PP = xfa.form.F.xxPage2.xPP.rawValue;<br /><br />//get city and state tax for the purchase price<br />state = statetax(PP);<br />city = citytax(PP);<br /><br />//xfa.form.F.xxPage2.xguc_city.rawValue = city;<br />//xfa.form.F.xxPage2.xguc_state.rawValue = state;<br /><br />//determine 'grossed- up' consideration<br />GUC = PP + state + city;<br />xfa.form.F.xxPage2.xGUC.rawValue = GUC;<br /><br />totaltax = state + city;<br />//app.alert(totaltax);<br /><br />//set the tax field value<br />xfa.form.F.xxPage2.xs1_line10.rawValue = totaltax;<br /><br />//set the taxrate field...<br />xfa.form.F.xxPage2.xp1.rawValue = percentage(GUC);<br /><br />}<br /><br />function citytax(PP)<br />{<br /> if (xfa.form.F.xxPage2.xtransfer_tax_nyc.rawValue == "buyer")<br /> {<br /> //buyer is responsible for the transfer tax...<br /> //do calculations accordingly<br /> //app.alert(percentage(PP));<br /> return (PP * (percentage(PP) / 100));<br /> <br /> }<br />else<br /> {<br /> xfa.form.F.xxPage2.xguc_city.rawValue = 0;<br /> return 0;<br /> }<br /><br />}<br /><br />function statetax(PP)<br />{<br />if (xfa.form.F.xxPage2.xtransfer_tax.rawValue == "buyer")<br /> {<br /> //buyer is responsible for the transfer tax...<br /> //do calculations accordingly<br /> //divide by 500<br /> nys = PP /500;<br /><br /> //round up to the nearest whole dollar<br /> nys = Math.ceil(nys);<br /><br /> //multiply this by 2<br /> return (nys * 2);<br /> }<br />else<br /> {<br /> return 0;<br /> }<br />}<br /><br />function percentage(consideration)<br />{<br />T_1 = xfa.form.F.xxPage1.xT_1.rawValue;<br />T_2 = xfa.form.F.xxPage1.xT_2.rawValue;<br />T_3 = xfa.form.F.xxPage1.xT_3.rawValue;<br /><br />//if (xfa.form.F.xxPage1.xT_1.rawValue == "" &amp;&amp; xfa.form.F.xxPage1.xT_2.rawValue == "" &amp;&amp; xfa.form.F.xxPage1.xT_3.rawValue == "" &amp;&amp; //xfa.form.F.xxPage1.xT_4.rawValue == "" &amp;&amp; xfa.form.F.xxPage1.xT_5.rawValue == "" &amp;&amp; xfa.form.F.xxPage1.xT_6.rawValue == "" &amp;&amp; //xfa.form.F.xxPage1.xT_7.rawValue == "" &amp;&amp; xfa.form.F.xxPage1.xT_8.rawValue == "")/<br />//{<br /> // T_1 = "X";<br />//}<br /><br />if ((T_1=="X") || (T_2=="X") || (T_3=="X"))<br /> //It's residential...apply appropriate percentages...<br /> {<br /> //app.alert('residential');<br /> if (consideration &lt;= 500000)<br /> return 1;<br /> else<br /> return 1.425; <br /> }<br />else<br /> //It's commercial...apply appropriate percentages...<br /> {<br /> if (consideration &lt;= 500000)<br /> return 1.425;<br /> else<br /> return 2.625;<br /> }<br />}</script>