J
|
Jane 4/10/2009 |
Hi, <script> var x = document.editform.value_MON1; var y = document.editform.value_MON2; x.onchange = x.onkeyup = y.onchange = y.onkeyup = function() { document.editform.value_MTOT.value = document.editform.value_MON1.value + document.editform.value_MON2.value; } </script> |
R
|
racerx author 4/10/2009 |
Hi, here is just a sample:
|
J
|
Jane 4/10/2009 |
Hi, var mon1 = document.editform.value_MON1.value; var mon2 = document.editform.value_MON2.value; document.editform.value_MTOT.value = mon1.toFixed() + mon2.toFixed();
|
R
|
racerx author 4/10/2009 |
Hi, use toFixed() function: More info here: http://www.w3schools.com/jsref/jsref_tofixed.asp
|
![]() |
Sergey Kornilov admin 4/10/2009 |
racerx, |
R
|
racerx author 4/11/2009 |
racerx, toFixed() function converts strings to numbers so it can summed properly. If you don't convert strings to numbers it concatenate strings ( 8 + 8 = 88 instead of 8 + 8 = 16).
|
J
|
Jane 4/13/2009 |
Hi, <script> var x = document.forms.editform.value_MON1; var y = document.forms.editform.value_MON2; x.onchange = x.onkeyup = y.onchange =y.onkeyup = function() { var mon1 = document.forms.editform.value_MON1.value; var mon2 = document.forms.editform.value_MON2.value; document.forms.editform.value_MTOT.value = mon1.toFixed() + mon2.toFixed(); } </script> |
R
|
racerx author 4/13/2009 |
Hi, this code wo'nt work because you haveno't define mon1 and mon2 in your function:
|
J
|
Jane 4/13/2009 |
It's difficult to tell you what's happening without seeing actual files. |
R
|
racerx author 4/13/2009 |
It's difficult to tell you what's happening without seeing actual files. Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.
|
J
|
Jane 4/14/2009 |
Try to use this one: {literal}<script> var x = document.forms.editform.value_MON1; var y = document.forms.editform.value_MON2; var z = document.forms.editform.value_MON3; var a = document.forms.editform.value_MON4; var b = document.forms.editform.value_MON5; var c = document.forms.editform.value_MON6; x.onchange = x.onkeyup = y.onchange = y.onkeyup = z.onchange = z.onkeyup = a.onchange = a.onkeyup = b.onchange = b.onkeyup = c.onchange = c.onkeyup = function() { var mon1 = document.forms.editform.value_MON1.value; var mon2 = document.forms.editform.value_MON2.value; var mon3 = document.forms.editform.value_MON3.value; var mon4 = document.forms.editform.value_MON4.value; var mon5 = document.forms.editform.value_MON5.value; var mon6 = document.forms.editform.value_MON6.value; document.forms.editform.value_MTOT.value = Number(mon1) + Number(mon2) + Number(mon3) + Number(mon4) + Number(mon5) + Number(mon6); } </script> {/literal} |
R
|
racerx author 4/14/2009 |
Try to use this one:
|
L
|
laonian 4/14/2009 |
Thanks Jane for the wonderful coding. I have tried it in my test project in both Add and Edit pages and it works perfectly. But when I wanted to use it in List page with Inline Edit triggered, I could not get it work. How should I modify and where should I put it for Inline Edit page? Thanks. |
J
|
Jane 4/15/2009 |
Hi, |
G
|
gchable 6/17/2009 |
how to calculate fields in real time with Phpr 5.1? |
J
|
Jane 6/18/2009 |
Hi, |
G
|
gchable 6/18/2009 |
<html {$html_attrs}> |
J
|
Jane 6/19/2009 |
Hi, |
G
|
gchable 6/19/2009 |
Tks Jane, no good:
|
![]() |
Sergey Kornilov admin 6/19/2009 |
Try the following: <script> var x = document.forms.editform.value_MON1; var y = document.forms.editform.value_MON2; x.onchange = x.onkeyup = y.onchange = y.onkeyup = function() { var mon1 = new Number(document.forms.editform.value_MON1.value); var mon2 = new Number(document.forms.editform.value_MON2.value); document.forms.editform.value_MTOT.value = mon1.toFixed() + mon2.toFixed(); } </script> |
G
|
gchable 6/19/2009 |
that worked fine |