What’s new?
jQuery Calx version 2.0 is the successor of jQuery Calx 1.x. It offer a lot of new feature since version 1.x, let see what’s new in jQuery Calx 2.0
- Rewrite the internal formula parser and plugin structure.
- Ability to register new function and override default one.
- Ability to register variable.
- Easy graph to represent data in graphical way (additional library required)
- Add support for string and cell range.
- Add a lot of excel compatible function (additional library may be required).
- Add feature to check circular reference, instead of infinite loop which make the page hang up, it’s now alerting error.
- Add support for server-side function formula, in case you want to hide the calculation algorithm.
- Add support to change formula, value, format easily without need to write tricky script.
To support us developing more feature on jQuery Calx 2.x, you can fork and send a pull request on the github repository https://github.com/xsanisty/jquery-calx or you can send a donation to us.
Updating from 1.x
If you are using jQuery Calx 1.x and want to update to 2.x, here is some points you need to take care of.
Replace id with data-cell for cell addressing
jQuery Calx 2.x use data-cell attribute to set the cell-address, since there are possibility of two or more same cell-address in single page
<!-- previous --> <input id="A1" /> <!-- current --> <input data-cell="A1" />
No more $ sign in formula
In jQuery Calx 1.x, we use $A1 to get the value of cell with address A1, in 2.x we completely remove the $ sign and use the cell address directly to access it’s value
<!-- previous --> <input data-formula="SUM($A1,$B10)" /> <input data-formua="$D8-$D5" /> <!-- current --> <input data-formula="SUM(A1:B10)" /> <input data-formula="D8-D5" />
It seems like all versions of the Calx jquery plugin are not compatible with Google Analytics 4, and break the site. Any chance you’ll be able to fix this for compatibility before June 2023?
hi,
M trying to implement reverse calculation with jquery calx 2.2.8 and getting too much recursion error.
please suggest how to handle the error and how to implement reverse calculations
hi,
m trying to implement reverse calculation using jquery calx 2.2.8, and getting too much recursion error.
please guide how to handle it and achieve reverse calculation
halo mas, saya ada opportunity project. kemaren sempet kontak juga via form contact.
boleh minta tolong kirim email ke saya mas?
Terima kasih
Halo mas jhon, sudah saya balas via email ya 🙂
Halo mas jhon, bisa dibantu, saya buat yang dinamic form, pass aditem update tidak berjalan, adakah saran
halo mas iksan
tolong dibantu dong.
kalo hasil kalkulasi itu mau di save ke database gmn caranya,. karna tidak ada value . hanya data-formula di field property nya.
mhn dijawab y mas. terimakasih
Halo mas Ungki,
Bisa di serialize pake
$form.calx('getSheet').getCellRangeValue('A1', 'Z100')
, referensinya bisa dilihat disini https://www.xsanisty.com/project/calx2/sheet-api/mas jika value hasil penjumlahan yang terdapat di input calx apakah bisa diambil menggunakan jquery?
Halo kang Ikhsan,
Saya mau tanya, saya dapat error Cannot read properties of undefined (reading ‘isAffected’) dan Cannot read properties of undefined (reading ‘renderComputedValue’), bagaimana ya kang penyelesaiannya? Terimakasih
halo xsanisty , terimakasih sudah membuat aplikasi calx. saya mau tanya , kan saya pakai pembulatan data-format=”0.0000″. saya lihat di value dari input hasil pembulatan , bagaimana cara saya mengambil value sebelum pembulatan ?
terimakasih mas
Halo mas Diky,
untuk raw value, bisa pakai
$('#form').calx('getCell', 'A1').getValue()
Makasi. Librarynya berguna banget mas. Mau tanya
Kalo id nya input text pengen diisi bebas gimana ya mas. Misal t, a, v1v1.
Kalo yang saya coba bisanya kombinasi angka dan huruf kayak a1, b3 dst..
Makasi
Halo mas Ang,
Kalau id bisa bebas, karena calx 2 baca atribut data-cell buat referensinya
Terimakasih mas, jQuery calx nya mantep banget.
Mau tanya mas, bagaimana kita tahu trigger setelah suatu field selesai melakukan perhitungan? Saya ingin melakukan fungsi lain setelah field tersebut selesai melakukan perhitungan.
Jadi saya ada 3 input text untuk menampung total perhituungan debgan id total1, total2, total3
Ketika total1 selesai perhitungan akan melakukan update ke tabel 1
Total 2 ke tabel 2
Total 3 ke tabel 3
Halo mas Isakhar, bisa pake event
onAfterCalculate
yaCould you please explain how to add formula for Standard deviation
<input data-cell="B2" data-formula="IF(B1=1000,B11300,B1
IF语句算不出来 报错
How can we use custom attribute for value e.g data-price as for select, radio and checkbox it is submitting the number as value and we are manually manipulating it on submission which is not ideal, any easy way of making custom attribute for value? thank you so much for a great tool.
Hi khan
did you find any solution ?
dear ikhsan,
has calx an event witch fires, when init is ready or calculation is done?
Can anyone work with format. This plugin awesome but with numeral doenst work. There is no way to work together. It s always getting error “TypeError: x(…).unformat is not a function
at u.fx.init (jquery-calx-2.2.8.min.js:186)”
Unfortunately this error ruined my whole 2 days. So i am getting pure js….
Hi Harun,
newer release of numeral did break with calx, you can use the numeral shipped with calx
regards,
Ikhsan
Hi there !
Is there a way to use the data over several pages ?
Thanks a lot for your help.
Hi ikhsan,
I have a requirement to calculate based on percentage mix. I tried with formulas but it fails due to circular reference.
Could you please confirm if its possible ?
eg:
Current Updated
A1 100 = A2 + A3 150
A2 80 = (80/100) * new value 120
A3 20 = (20/100) * new value 30
If A2 or A3 is updated , A1 will be updated accordingly. But if total is updated then it would be distributed between A2 and A3 based on current percentage mix. If 100 is updated to 150 then A2 = 80 + 40 = 120 and A3 = 20 + 10 = 30.
hi … how to get alert when calx function is called
Hi,
I have a requirement to do my custom logic after calx has done the calculations for the fields. Is it possible to pass a callback method to calx OR how can we know when the data calculations are completed and we are good to proceed with our custom logic.
Please assist.
Hi Mayur, you can do the arbitrary process using onAfterCalculate event
Hi there,
I’m trying the calcx, so far so good, neat.
Just i ran into a problem
i can’t have the IF(RES3>150,VAL1*0.25,VAL1*0.75) working. I have a true false output or if i add +IF(…) 0 or 1
Even the provided demo works this way.Could i missed some point?
Thanx for the job u did.
Hi Samy,
There is some bug in prior version that comparison operator need space between it, like IF(RES3 > 150,VAL1*0.25,VAL1*0.75)
But I think that issue is fixed, will check it again
Hi, in which version this is solved could you please tell me I am faicng same issue
Dear ikhsan,
i need to pickup a row with a named attribute rowname=’example’ something like this “….
and to return a column from this row.
My Idea is to create a custom definied formula and use jquery inside this formula to do this.
What do you think, is it possible?
Ok, i tried out and it works. i just added a new function in lib and used jquery to find my row and finaly return the given text of a td in that row.
FINDROWBYJQ: function(rowName,colName) {
colName = colName.toUpperCase();
rowName = rowName.toLowerCase();
var colNames = {'B':3,'C':4,'D':5,'E':6,'F':7,'G':8,'H':9,'I':10,'J':11,'K':12};
var col = colNames[colName];
var result = $("#mytable tbody tr[rowname="+rowName+"]").children('td').eq(col).text();
return result;
}
Dear ikhsan,
is there for the topic above another querstion:
Is there a way to get the current table name (id) inside the formula-definition for use in my jquery-idea?
Hello, tks for plugins, i need you one solve, i need you one conditional switch, or IF(mount1>mount2 and mount1<mount3),"price1","price2") it's possible this form ?, what ?, example ? tks very much for your colaborations.
Hi Leonardo,
with Calx 2, you can wrap it in
AND()
functionWork perfect, 1.000 thanks, it´s possible join if ?, i need you join conditional or switch example
IF(AND(X1>1000000, X12000000, X13000000, X14000000), ‘defautl’, ”)
OR switch
switch(X1) {
case (X1>1000000, X12000000, X1<3000000):
price 2
break;
default:
price 3
}
It' s possible this in calcx ?
http://leonetcomunicaciones.com/cotizador-online/calculadora-gastos-registro.htm
Calx works similar with excel or any spreadsheet app if you are familiar with it.
for multiple condition, you can use multiple IFs
regards,
Ikhsan
Tks very much, work fine, you are excellent !!!
Hi, great plugin,
I have an issue using calx, I am using c# mvc (bundle), sometimes I get an error saying that does not recognize calx (console says – Object doesn´t support property or method ´calx´) like if the js file was not loaded by the browser. The error is on IE 11. The order which I am using to load the files are (always loads on the same order):
1. jquery version 2.2
2. numeral version 1.5.3
3. moment version 2.17.1
4. calx version 2.2.7
My last test was changing the name of the js file trying to avoid cache or somtething like that.
Do you have an idea how to fix this issue?
Best Regards
Are you still supporting calx? I think this is a wonderful tool and love what you have done with it.
I downloaded 2.2.7 from GitHub and have been playing with it for a few weeks now.
There is a report of a problem with the “IF” formula on GitHub.
I’ve experienced the same problem where it returns TRUE or FALSE instead of the intended result.
Is there any chance you might still be planning to take a look at this?
I’m hoping so, because this is such a good project.
Best Wishes!
Hi Rich,
Thanks for your kind words.
Yes, we are still supporting it, I am currently the only one in charge to maintain jQuery Calx, but I need to focus on client’s project, the other team members are still on duty too, so actually, we are out of resources, resulting in no update and issue resolve in past half year.
Regarding to IF issue, how you write your formula? as I have no problem with this. You can take a look at http://www.vancomycin-calculator.com/ , there are a lot of IF function used on this page, and it works as intended.
Best regards,
Ikhsan
Hello,
I am doing a project based on your excellent lib.
I found a bug on version 2.2.7. If I call method ‘update’ then the cells stop working.
If I click on a cell then no decimal values are displayed and cells randomly get NaN values.
Would you be so kind and check this issue?
Regards,
Uros
I, excellent job. Just to inform you that your code does not work with the most recent version of numeral due the “unformat” is not longer exists. Lines where unforrnat is used: 6094, 8550 and 9811.
Thanks, I’ll check and update it
Hi whenever i tried to put text value rather than a numeric value in form field it gave me error, for example, formula like
IF(A1=1,"Dance","Cook")
, can calx input text?you know what, i just realized, i need to change ” to ‘, because the whole formula is in ” “, sorry, just disregard my question, I don’t know how to delete my question, so i replied to my own question. still thanks for the great plugin, it really helps with my form.
Hi ikhsan,
Are there any limits in the number of tables?
I loadet 5 complex tables and initialized them to calx successful. Now i have to load a set of new tables in a second layer and calculate them. But when i do so, the tables in the first layer dont work any more.
Can you please help me?
Hi Bernd,
There should be no limitation on how many element can be initialized by calx, as long as they are unique, and make sure the query selector did not select previously initialized calx
Hi ikhsan,
Thanks for quick answer. Ok, i ‘ll check if selectors are unique
Hi ikhsan,
one Question: Are there any limits in the number of tables?
I loadet 5 complex tables and initialized them to calx successful. Now i have to load a set of new tables in a second layer and calculate them. But when i do so, the tables in the first layer dont work any more.
Can you please help me?
I’m trying to use the format ‘Letter”’Letter’ ‘Number’ for the data-cell property and it results in error, wich one is the range of the data-cell property??
How to create a IF conditional, not to show true and false in result?
IF(A1=1, myvalue true, myvalue false)
Thank you for a great script.
We have a registration form and would like to store the text value in a database after the form is submitted.
How should we define the calculation value to do so? We want to calculate but want to store “Event Name” if chosen into the database.
Event Name $150
Thank you.
Hi, I have a problem..
Can I define my unique value for price? For example:
<input type="radio" name="NameProduct" data-cell="A1" value="OptionNameProduct" price="10">
Or maybe he calculate not from value of input?
Because, I can’t submit options product to next step 🙂
Thanks for your reply!
Best regards,
Christopher
Hi!
Why is written: #ERROR! #ERROR! $ 0.00 0
as a result of such code:
Best regards,
Andry
Hi Andry,
it seems your code is truncated, can you use the ‘crayon’ button in the comment to add your code?
regards,
Ikhsan
How i can operate with new attribute? Example:
Some text
How i can use attribute “data-next” in calculate?
Please help 🙁
Hi Mex,
can you post the code sample using the “crayon” button in the comment section?
Example:
I need calculate with data-next value. It is possible? Not with default attribute value but custom attribute, for example (data-next)
maybe you can try something like
$(‘#form’).calx({
data:{
C2:{ value: $(‘[data-cell=”C2″]’).attr(‘data-next’)}
}
});
Ikhsan,
i have select in row and this select have two attributes (value and data-next). I need to use in the calculation of both values. But i dont know how.
for the select box, calx will take the option value, and I think it will be ambiguous to take number from 2 different attributes
Hi,
In addition to Mex, I think i’ve the same problem. From the select box, I want the value to be placed in the database (using php) and use an separate data-price attribute to do the calculations. I’ve tryed to place the in an hidden input, that works, but Calx will not reconize the input for further calculations.
It would be a great if you could help me! Thanks.